rbs 3.0.0.dev.1 → 3.0.0.dev.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -3
  3. data/CHANGELOG.md +28 -0
  4. data/Gemfile.lock +2 -2
  5. data/README.md +1 -0
  6. data/Rakefile +75 -1
  7. data/core/array.rbs +1 -1
  8. data/core/builtin.rbs +1 -1
  9. data/core/hash.rbs +1 -1
  10. data/core/module.rbs +1 -1
  11. data/ext/rbs_extension/constants.c +16 -2
  12. data/ext/rbs_extension/constants.h +8 -1
  13. data/ext/rbs_extension/extconf.rb +1 -1
  14. data/ext/rbs_extension/lexer.c +834 -777
  15. data/ext/rbs_extension/lexer.h +3 -1
  16. data/ext/rbs_extension/lexer.re +3 -1
  17. data/ext/rbs_extension/lexstate.c +4 -2
  18. data/ext/rbs_extension/parser.c +264 -44
  19. data/ext/rbs_extension/ruby_objs.c +56 -2
  20. data/ext/rbs_extension/ruby_objs.h +7 -1
  21. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  22. data/lib/rbs/ast/declarations.rb +49 -2
  23. data/lib/rbs/ast/directives.rb +39 -0
  24. data/lib/rbs/cli.rb +32 -18
  25. data/lib/rbs/collection/config/lockfile_generator.rb +25 -20
  26. data/lib/rbs/collection/config.rb +2 -2
  27. data/lib/rbs/collection/sources/git.rb +1 -1
  28. data/lib/rbs/definition_builder/ancestor_builder.rb +24 -8
  29. data/lib/rbs/definition_builder.rb +8 -8
  30. data/lib/rbs/environment/use_map.rb +77 -0
  31. data/lib/rbs/environment.rb +352 -83
  32. data/lib/rbs/environment_loader.rb +9 -7
  33. data/lib/rbs/environment_walker.rb +1 -1
  34. data/lib/rbs/errors.rb +34 -37
  35. data/lib/rbs/locator.rb +1 -1
  36. data/lib/rbs/parser_aux.rb +8 -6
  37. data/lib/rbs/resolver/constant_resolver.rb +23 -7
  38. data/lib/rbs/resolver/type_name_resolver.rb +2 -1
  39. data/lib/rbs/sorter.rb +3 -3
  40. data/lib/rbs/test/setup.rb +1 -1
  41. data/lib/rbs/type_alias_dependency.rb +1 -1
  42. data/lib/rbs/type_alias_regularity.rb +3 -3
  43. data/lib/rbs/validator.rb +23 -2
  44. data/lib/rbs/variance_calculator.rb +2 -2
  45. data/lib/rbs/version.rb +1 -1
  46. data/lib/rbs/writer.rb +28 -2
  47. data/lib/rbs.rb +2 -2
  48. data/lib/rdoc_plugin/parser.rb +2 -2
  49. data/rbs.gemspec +1 -1
  50. data/sig/ancestor_graph.rbs +22 -2
  51. data/sig/collection/config/lockfile_generator.rbs +8 -10
  52. data/sig/collection/config.rbs +1 -1
  53. data/sig/collection/sources.rbs +12 -6
  54. data/sig/constant.rbs +1 -1
  55. data/sig/declarations.rbs +36 -3
  56. data/sig/definition.rbs +1 -1
  57. data/sig/definition_builder.rbs +0 -1
  58. data/sig/directives.rbs +61 -0
  59. data/sig/environment.rbs +150 -28
  60. data/sig/environment_loader.rbs +1 -1
  61. data/sig/errors.rbs +22 -1
  62. data/sig/parser.rbs +8 -15
  63. data/sig/resolver/constant_resolver.rbs +1 -2
  64. data/sig/shims/bundler.rbs +18 -0
  65. data/sig/shims/rubygems.rbs +6 -0
  66. data/sig/use_map.rbs +35 -0
  67. data/sig/validator.rbs +12 -5
  68. data/sig/writer.rbs +4 -2
  69. metadata +7 -9
  70. data/lib/rbs/constant_table.rb +0 -167
  71. data/lib/rbs/type_name_resolver.rb +0 -67
  72. data/sig/constant_table.rbs +0 -30
  73. data/sig/type_name_resolver.rbs +0 -26
  74. data/steep/Gemfile +0 -3
  75. data/steep/Gemfile.lock +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a07433a652ee9bdc6b90162eb974d289fafabed916044ffa8e83b78063b8c0b
4
- data.tar.gz: 1339eae3040ab4714dd241497bbc20d643ae5eaef62b03a02138806ecf4737c5
3
+ metadata.gz: 37f0e00e909c3e55bf8f8a80187fe4825d325e8b5ffc392d749058dba6d37561
4
+ data.tar.gz: 541db099d371d39611212952a07f545be143dd26845532665ee3f7c48fe5e3f7
5
5
  SHA512:
6
- metadata.gz: 8b414da0d750aefbfdaadcd0a309d2ee4157969112f6806149597fd402b4ca43aaae5cbf162e14f7bfe0a21e3369fad2b94a54f5d3610e15362afd2bd9d83d8f
7
- data.tar.gz: 884514e8cf52edbd3e17b6c214cd113b58a6107b4a00f73f826d471521d883997a3bee6c3f0c3e7a2770e23468e6a964878504f1a5cf7de9a6ab2d5ec66fbb4e
6
+ metadata.gz: 68e344e08d8aa8333dc8a4c4292e8b45ba7eab22027c570dc7c18f5e9f86289914ee742261e423bb5ea2924ccb3cbf9516de67150f86a8dd6aabdf573404c1ed
7
+ data.tar.gz: 680e1b9be1495dae9c1842c7e5b49984c819fe2c54fea9002d3508727b60847bc0fbee737ef2625f603e00406f612008f9b515be37cb662ed5dd4ee1b4af736f
@@ -6,9 +6,6 @@ on:
6
6
  - master
7
7
  pull_request: {}
8
8
 
9
- env:
10
- LANG: 'C.UTF-8'
11
-
12
9
  jobs:
13
10
  test:
14
11
  runs-on: "ubuntu-latest"
data/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.8.4 (2023-01-20)
6
+
7
+ ### Miscellaneous
8
+
9
+ * Make `rake stdlib_test` run with single process (Backport [#1207](https://github.com/ruby/rbs/pull/1207), [#1211](https://github.com/ruby/rbs/pull/1211))
10
+ * Remove `steep/*` files from `.gem` (Backport [#1214](https://github.com/ruby/rbs/pull/1214), [#1216](https://github.com/ruby/rbs/pull/1216))
11
+
12
+ ## 2.8.3 (2023-01-06)
13
+
14
+ ### Library changes
15
+
16
+ * Use `-std=gnu99` instead of `-std=c99` (Backport [#973](https://github.com/ruby/rbs/pull/973))
17
+ * Add `rbs_` prefix to `skip` function (Backport [#1186](https://github.com/ruby/rbs/pull/1186))
18
+
19
+ ## 2.8.2 (2022-12-21)
20
+
21
+ ### Signature updates
22
+
23
+ * `YAML.load` ([#1170](https://github.com/ruby/rbs/pull/1170))
24
+
25
+ ### Library changes
26
+
27
+ * Add the methods of the `prepend`ed module itself ([#1182](https://github.com/ruby/rbs/pull/1182))
28
+
29
+ ### Miscellaneous
30
+
31
+ * Add `TestSkip` module to skip tests that fails in ruby CI ([#1167](https://github.com/ruby/rbs/pull/1167))
32
+
5
33
  ## 2.8.1 (2022-11-28)
6
34
 
7
35
  ### Signature updates
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs (3.0.0.dev.1)
4
+ rbs (3.0.0.dev.2)
5
5
 
6
6
  PATH
7
7
  remote: test/assets/test-gem
@@ -115,4 +115,4 @@ DEPENDENCIES
115
115
  test-unit
116
116
 
117
117
  BUNDLED WITH
118
- 2.3.14
118
+ 2.4.6
data/README.md CHANGED
@@ -131,6 +131,7 @@ puts singleton.methods[:gsub]
131
131
  - [Writing signatures guide](docs/sigs.md)
132
132
  - [Stdlib signatures guide](docs/stdlib.md)
133
133
  - [Syntax](docs/syntax.md)
134
+ - [RBS by Example](docs/rbs_by_example.md)
134
135
 
135
136
  ## Development
136
137
 
data/Rakefile CHANGED
@@ -69,7 +69,15 @@ FileList["test/stdlib/**/*_test.rb"].each do |test|
69
69
  task test => :compile do
70
70
  sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test}"
71
71
  end
72
- task stdlib_test: test
72
+ end
73
+
74
+ task :stdlib_test do
75
+ test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
76
+ path =~ %r{Ractor}
77
+ end
78
+ sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
79
+ # TODO: Ractor tests need to be run in a separate process
80
+ sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
73
81
  end
74
82
 
75
83
  task :rubocop do
@@ -225,3 +233,69 @@ task :test_generate_stdlib do
225
233
  sh "RBS_GENERATE_TEST_PATH=/tmp/Thread_Mutex_test.rb rake 'generate:stdlib_test[Thread::Mutex]'"
226
234
  sh "ruby -c /tmp/Thread_Mutex_test.rb"
227
235
  end
236
+
237
+ Rake::Task[:release].enhance do
238
+ Rake::Task[:"release:note"].invoke
239
+ end
240
+
241
+ namespace :release do
242
+ desc "Explain the post-release steps automatically"
243
+ task :note do
244
+ version = Gem::Version.new(RBS::VERSION)
245
+ major, minor, patch, *_ = RBS::VERSION.split(".")
246
+ major = major.to_i
247
+ minor = minor.to_i
248
+ patch = patch.to_i
249
+
250
+ puts "🎉🎉🎉🎉 Congratulations for **#{version}** release! 🎉🎉🎉🎉"
251
+ puts
252
+ puts "There are a few things left to complete the release. 💪"
253
+ puts
254
+
255
+ if patch == 0 || version.prerelease?
256
+ puts "* [ ] Update release note: https://github.com/ruby/rbs/wiki/Release-Note-#{major}.#{minor}"
257
+ end
258
+
259
+ if patch == 0 && !version.prerelease?
260
+ puts "* [ ] Delete `RBS XYZ is the latest version of...` from release note: https://github.com/ruby/rbs/wiki/Release-Note-#{major}.#{minor}"
261
+ end
262
+
263
+ puts "* [ ] Publish a release at GitHub"
264
+ puts "* [ ] Make some announcements on Twitter/Mustdon/Slack/???"
265
+
266
+ puts
267
+ puts
268
+
269
+ puts "✏️ Making a draft release on GitHub..."
270
+
271
+ content = File.read(File.join(__dir__, "CHANGELOG.md"))
272
+ changelog = content.scan(/^## \d.*?(?=^## \d)/m)[0]
273
+ changelog = changelog.sub(/^.*\n^.*\n/, "").rstrip
274
+
275
+ notes = <<NOTES
276
+ [Release note](https://github.com/ruby/rbs/wiki/Release-Note-#{major}.#{minor})
277
+
278
+ #{changelog}
279
+ NOTES
280
+
281
+ command = [
282
+ "gh",
283
+ "release",
284
+ "create",
285
+ "--draft",
286
+ "v#{RBS::VERSION}",
287
+ "--title=#{RBS::VERSION}",
288
+ "--notes=#{notes}"
289
+ ]
290
+
291
+ if version.prerelease?
292
+ command << "--prerelease"
293
+ end
294
+
295
+ require "open3"
296
+ output, status = Open3.capture2(*command)
297
+ if status.success?
298
+ puts " >> Done! Open #{output.chomp} and publish the release!"
299
+ end
300
+ end
301
+ end
data/core/array.rbs CHANGED
@@ -850,7 +850,7 @@ class Array[unchecked out Elem] < Object
850
850
  #
851
851
  # Array#slice is an alias for Array#[].
852
852
  #
853
- def []: (int index) -> Elem
853
+ def []: %a{implicitly-returns-nil} (int index) -> Elem
854
854
  | (int start, int length) -> ::Array[Elem]?
855
855
  | (::Range[::Integer?] range) -> ::Array[Elem]?
856
856
 
data/core/builtin.rbs CHANGED
@@ -23,7 +23,7 @@ interface _ToHash[K, V]
23
23
  end
24
24
 
25
25
  interface _ToProc
26
- def to_proc: () -> untyped
26
+ def to_proc: () -> Proc
27
27
  end
28
28
 
29
29
  interface _ToPath
data/core/hash.rbs CHANGED
@@ -698,7 +698,7 @@ class Hash[unchecked out K, unchecked out V] < Object
698
698
  # h = {foo: 0, bar: 1, baz: 2}
699
699
  # h[:nosuch] # => nil
700
700
  #
701
- def []: (K arg0) -> V
701
+ def []: %a{implicitly-returns-nil} (K arg0) -> V
702
702
 
703
703
  # <!--
704
704
  # rdoc-file=hash.c
data/core/module.rbs CHANGED
@@ -1536,5 +1536,5 @@ class Module < Object
1536
1536
  # `attr_reader(name)` but deprecated. Returns an array of defined method names
1537
1537
  # as symbols.
1538
1538
  #
1539
- def attr: (*Symbol | String arg0) -> NilClass
1539
+ def attr: (*Symbol | String arg0) -> Array[Symbol]
1540
1540
  end
@@ -10,7 +10,7 @@ VALUE RBS_AST_TypeParam;
10
10
 
11
11
  VALUE RBS_AST_Declarations;
12
12
 
13
- VALUE RBS_AST_Declarations_Alias;
13
+ VALUE RBS_AST_Declarations_TypeAlias;
14
14
  VALUE RBS_AST_Declarations_Constant;
15
15
  VALUE RBS_AST_Declarations_Global;
16
16
  VALUE RBS_AST_Declarations_Interface;
@@ -18,6 +18,13 @@ VALUE RBS_AST_Declarations_Module;
18
18
  VALUE RBS_AST_Declarations_Module_Self;
19
19
  VALUE RBS_AST_Declarations_Class;
20
20
  VALUE RBS_AST_Declarations_Class_Super;
21
+ VALUE RBS_AST_Declarations_ModuleAlias;
22
+ VALUE RBS_AST_Declarations_ClassAlias;
23
+
24
+ VALUE RBS_AST_Directives;
25
+ VALUE RBS_AST_Directives_Use;
26
+ VALUE RBS_AST_Directives_Use_SingleClause;
27
+ VALUE RBS_AST_Directives_Use_WildcardClause;
21
28
 
22
29
  VALUE RBS_AST_Members;
23
30
  VALUE RBS_AST_Members_Alias;
@@ -80,7 +87,7 @@ void rbs__init_constants(void) {
80
87
 
81
88
  RBS_AST_Declarations = rb_const_get(RBS_AST, rb_intern("Declarations"));
82
89
 
83
- RBS_AST_Declarations_Alias = rb_const_get(RBS_AST_Declarations, rb_intern("Alias"));
90
+ RBS_AST_Declarations_TypeAlias = rb_const_get(RBS_AST_Declarations, rb_intern("TypeAlias"));
84
91
  RBS_AST_Declarations_Constant = rb_const_get(RBS_AST_Declarations, rb_intern("Constant"));
85
92
  RBS_AST_Declarations_Global = rb_const_get(RBS_AST_Declarations, rb_intern("Global"));
86
93
  RBS_AST_Declarations_Interface = rb_const_get(RBS_AST_Declarations, rb_intern("Interface"));
@@ -88,6 +95,13 @@ void rbs__init_constants(void) {
88
95
  RBS_AST_Declarations_Module_Self = rb_const_get(RBS_AST_Declarations_Module, rb_intern("Self"));
89
96
  RBS_AST_Declarations_Class = rb_const_get(RBS_AST_Declarations, rb_intern("Class"));
90
97
  RBS_AST_Declarations_Class_Super = rb_const_get(RBS_AST_Declarations_Class, rb_intern("Super"));
98
+ RBS_AST_Declarations_ClassAlias = rb_const_get(RBS_AST_Declarations, rb_intern("ClassAlias"));
99
+ RBS_AST_Declarations_ModuleAlias = rb_const_get(RBS_AST_Declarations, rb_intern("ModuleAlias"));
100
+
101
+ RBS_AST_Directives = rb_const_get(RBS_AST, rb_intern("Directives"));
102
+ RBS_AST_Directives_Use = rb_const_get(RBS_AST_Directives, rb_intern("Use"));
103
+ RBS_AST_Directives_Use_SingleClause = rb_const_get(RBS_AST_Directives_Use, rb_intern("SingleClause"));
104
+ RBS_AST_Directives_Use_WildcardClause = rb_const_get(RBS_AST_Directives_Use, rb_intern("WildcardClause"));
91
105
 
92
106
  RBS_AST_Members = rb_const_get(RBS_AST, rb_intern("Members"));
93
107
  RBS_AST_Members_Alias = rb_const_get(RBS_AST_Members, rb_intern("Alias"));
@@ -9,7 +9,7 @@ extern VALUE RBS_AST_Comment;
9
9
  extern VALUE RBS_AST_TypeParam;
10
10
 
11
11
  extern VALUE RBS_AST_Declarations;
12
- extern VALUE RBS_AST_Declarations_Alias;
12
+ extern VALUE RBS_AST_Declarations_TypeAlias;
13
13
  extern VALUE RBS_AST_Declarations_Class_Super;
14
14
  extern VALUE RBS_AST_Declarations_Class;
15
15
  extern VALUE RBS_AST_Declarations_Constant;
@@ -17,6 +17,13 @@ extern VALUE RBS_AST_Declarations_Global;
17
17
  extern VALUE RBS_AST_Declarations_Interface;
18
18
  extern VALUE RBS_AST_Declarations_Module_Self;
19
19
  extern VALUE RBS_AST_Declarations_Module;
20
+ extern VALUE RBS_AST_Declarations_ModuleAlias;
21
+ extern VALUE RBS_AST_Declarations_ClassAlias;
22
+
23
+ extern VALUE RBS_AST_Directives;
24
+ extern VALUE RBS_AST_Directives_Use;
25
+ extern VALUE RBS_AST_Directives_Use_SingleClause;
26
+ extern VALUE RBS_AST_Directives_Use_WildcardClause;
20
27
 
21
28
  extern VALUE RBS_AST_Members;
22
29
  extern VALUE RBS_AST_Members_Alias;
@@ -1,4 +1,4 @@
1
1
  require 'mkmf'
2
2
  $INCFLAGS << " -I$(top_srcdir)" if $extmk
3
- append_cflags ['-std=c99']
3
+ append_cflags ['-std=gnu99']
4
4
  create_makefile 'rbs_extension'