rbs 3.6.0 → 3.7.0.dev.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb0b6146ae3fb623941640740fb04a27f47944f69c7c8392eecbe483fdc585d
4
- data.tar.gz: eac17e29129ce5d87886a3405c9a5f3e3088f1f7d4ff593e1bd4237b4d4753c6
3
+ metadata.gz: 86a893f83a116311b7161ef437a811c4c81adae584063b690acf0711f94eb633
4
+ data.tar.gz: d5cdbec208cd2c8c7671712e1e94215e1d83ea487d6eb9eca8499d0d3016b9a0
5
5
  SHA512:
6
- metadata.gz: 3b41c024be368fb48a31c479a07362040e5165dd965eb60d7a9c805dbae8be1f23f16a9473922eb75965cf02ffff99beb35a9c8f27485b435e0658410abba00f
7
- data.tar.gz: 193ee4fe30508c89f8c3ee548b5ab6d4839c57afacac7ef02e9aa0d0fb71c1886f87e85a2d659af03551c63c23797af7c6d54260b7be2095e74f69ca194852ce
6
+ metadata.gz: e17695da454b8df97db782759c1e63f7d01af6a33ec258c43ec0c1759fa6c768d83e4b9a5cd98c7229370bfad0c2865c202b06fcb86568821ec62148139fbbf0
7
+ data.tar.gz: 274d1c7db8d8e97e68ede7d0f21ed69b9a2403243c1f5c0e1c02429b669f3b0ff1d6c28e8c7d64b4ff658bd22c4f20b0d3318bf396e1cdd6dcca8ceca9f2bb3c
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: ['3.0', '3.1', '3.2', '3.3', head]
16
+ ruby: ['3.1', '3.2', '3.3', head]
17
17
  rubyopt: [""]
18
18
  job:
19
19
  - test
@@ -34,6 +34,8 @@ jobs:
34
34
  job: rubocop validate test_doc build test_generate_stdlib raap
35
35
  - ruby: "3.3"
36
36
  job: typecheck_test
37
+ env:
38
+ RANDOMIZE_STDLIB_TEST_ORDER: "true"
37
39
  steps:
38
40
  - uses: actions/checkout@v4
39
41
  - uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 1.8.0 (2024-09-30)
3
+ ## 3.6.1 (2024-10-03)
4
+
5
+ ### Library changes
6
+
7
+ * Mark as ractor-safe ([#2041](https://github.com/ruby/rbs/pull/2041))
8
+
9
+ ### Miscellaneous
10
+
11
+ * Omit IOConsoleTest with Windows platform ([#2044](https://github.com/ruby/rbs/pull/2044))
12
+ * Recover `$stdout` after test ([#2042](https://github.com/ruby/rbs/pull/2042))
13
+
14
+ ## 3.6.0 (2024-09-30)
4
15
 
5
16
  Nothing changed since `3.6.0.pre.3`.
6
17
 
data/Rakefile CHANGED
@@ -63,7 +63,12 @@ task :validate => :compile do
63
63
  # Skip RBS validation because Ruby CI runs without rubygems
64
64
  case skip_rbs_validation = ENV["SKIP_RBS_VALIDATION"]
65
65
  when nil
66
- libs << "rbs"
66
+ begin
67
+ Gem::Specification.find_by_name("rbs")
68
+ libs << "rbs"
69
+ rescue Gem::MissingSpecError
70
+ STDERR.puts "🚨🚨🚨🚨 Skipping `rbs` gem because it's not found"
71
+ end
67
72
  when "true"
68
73
  # Skip
69
74
  else
@@ -86,6 +91,11 @@ task :stdlib_test => :compile do
86
91
  test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
87
92
  path =~ %r{Ractor} || path =~ %r{Encoding}
88
93
  end
94
+
95
+ if ENV["RANDOMIZE_STDLIB_TEST_ORDER"] == "true"
96
+ test_files.shuffle!
97
+ end
98
+
89
99
  sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
90
100
  # TODO: Ractor tests need to be run in a separate process
91
101
  sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
data/core/io.rbs CHANGED
@@ -1638,7 +1638,7 @@ class IO < Object
1638
1638
  # Optional keyword argument `chomp` specifies whether line separators are to be
1639
1639
  # omitted.
1640
1640
  #
1641
- def readline: (?String sep, ?Integer limit) -> String
1641
+ def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
1642
1642
 
1643
1643
  # <!--
1644
1644
  # rdoc-file=io.c
@@ -1701,7 +1701,7 @@ class IO < Object
1701
1701
  # # => ["First line", "Second line", "", "Fourth line", "Fifth line"]
1702
1702
  # f.close
1703
1703
  #
1704
- def readlines: (?String sep, ?Integer limit) -> ::Array[String]
1704
+ def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
1705
1705
 
1706
1706
  # <!--
1707
1707
  # rdoc-file=io.c
data/core/kernel.rbs CHANGED
@@ -1209,7 +1209,7 @@ module Kernel : BasicObject
1209
1209
  # -->
1210
1210
  # Equivalent to Proc.new.
1211
1211
  #
1212
- def self?.proc: () { () -> untyped } -> Proc
1212
+ def self?.proc: () { (?) -> untyped } -> Proc
1213
1213
 
1214
1214
  # <!--
1215
1215
  # rdoc-file=proc.c
@@ -3,6 +3,9 @@
3
3
  void
4
4
  Init_rbs_extension(void)
5
5
  {
6
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
7
+ rb_ext_ractor_safe(true);
8
+ #endif
6
9
  rbs__init_constants();
7
10
  rbs__init_location();
8
11
  rbs__init_parser();
@@ -54,7 +54,7 @@ typedef struct {
54
54
 
55
55
  static VALUE EMPTY_ARRAY;
56
56
 
57
- static void inline melt_array(VALUE *array) {
57
+ static inline void melt_array(VALUE *array) {
58
58
  if (*array == EMPTY_ARRAY) {
59
59
  *array = rb_ary_new();
60
60
  }
@@ -9,14 +9,6 @@
9
9
  #include "constants.h"
10
10
  #include "ruby_objs.h"
11
11
 
12
- /**
13
- * Unescape escape sequences in the given string inplace:
14
- *
15
- * '\\n' => "\n"
16
- *
17
- * */
18
- void rbs_unescape_string(VALUE string, bool dq_string);
19
-
20
12
  /**
21
13
  * Receives `parserstate` and `range`, which represents a string token or symbol token, and returns a string VALUE.
22
14
  *
@@ -28,12 +28,18 @@ module RBS
28
28
  attr_reader :member
29
29
  attr_reader :defined_in
30
30
  attr_reader :implemented_in
31
+ attr_reader :member_annotations
32
+ attr_reader :overload_annotations
33
+ attr_reader :annotations
31
34
 
32
- def initialize(type:, member:, defined_in:, implemented_in:)
35
+ def initialize(type:, member:, defined_in:, implemented_in:, overload_annotations: [])
33
36
  @type = type
34
37
  @member = member
35
38
  @defined_in = defined_in
36
39
  @implemented_in = implemented_in
40
+ @member_annotations = member.annotations
41
+ @overload_annotations = overload_annotations
42
+ @annotations = member.annotations + overload_annotations
37
43
  end
38
44
 
39
45
  def ==(other)
@@ -54,12 +60,8 @@ module RBS
54
60
  member.comment
55
61
  end
56
62
 
57
- def annotations
58
- member.annotations
59
- end
60
-
61
63
  def update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in)
62
- TypeDef.new(type: type, member: member, defined_in: defined_in, implemented_in: implemented_in)
64
+ TypeDef.new(type: type, member: member, defined_in: defined_in, implemented_in: implemented_in, overload_annotations: overload_annotations)
63
65
  end
64
66
 
65
67
  def overload?
@@ -82,7 +84,7 @@ module RBS
82
84
  @super_method = super_method
83
85
  @defs = defs
84
86
  @accessibility = accessibility
85
- @extra_annotations = annotations
87
+ @extra_annotations = []
86
88
  @alias_of = alias_of
87
89
  end
88
90
 
@@ -124,7 +126,7 @@ module RBS
124
126
  end
125
127
 
126
128
  def annotations
127
- @annotations ||= @extra_annotations + defs.flat_map {|d| d.annotations }
129
+ @annotations ||= defs.flat_map {|d| d.member_annotations }
128
130
  end
129
131
 
130
132
  def members
@@ -386,7 +386,8 @@ module RBS
386
386
  type: method_type,
387
387
  member: initialize_def.member,
388
388
  defined_in: initialize_def.defined_in,
389
- implemented_in: initialize_def.implemented_in
389
+ implemented_in: initialize_def.implemented_in,
390
+ overload_annotations: initialize_def.overload_annotations
390
391
  )
391
392
  end,
392
393
  accessibility: :public,
@@ -641,7 +642,8 @@ module RBS
641
642
  type: subst.empty? ? overload.method_type : overload.method_type.sub(subst),
642
643
  member: original,
643
644
  defined_in: defined_in,
644
- implemented_in: implemented_in
645
+ implemented_in: implemented_in,
646
+ overload_annotations: overload.annotations
645
647
  )
646
648
  end
647
649
 
@@ -750,7 +752,8 @@ module RBS
750
752
  type: subst.empty? ? overload.method_type : overload.method_type.sub(subst),
751
753
  member: overloading_def,
752
754
  defined_in: defined_in,
753
- implemented_in: implemented_in
755
+ implemented_in: implemented_in,
756
+ overload_annotations: overload.annotations
754
757
  )
755
758
 
756
759
  method_definition.defs.unshift(type_def)
data/lib/rbs/test/hook.rb CHANGED
@@ -96,50 +96,55 @@ def #{with_name}(#{param_source.join(", ")}, &#{block_param})
96
96
  block_calls = []
97
97
 
98
98
  if block_given?
99
- receiver = self
100
99
  block_receives_block = #{block_param}.parameters.last&.yield_self {|type, _| type == :block }
101
100
 
102
- wrapped_block = proc do |*block_args, &block2|
103
- return_from_block = false
104
-
105
- begin
106
- block_result = if receiver.equal?(self)
107
- if block_receives_block
108
- #{block_param}.call(*block_args, &block2)
109
- else
110
- yield(*block_args)
111
- end
112
- else
113
- instance_exec(*block_args, &#{block_param})
114
- end
115
-
116
- return_from_block = true
117
- ensure
118
- exn = $!
119
-
120
- case
121
- when return_from_block
122
- # Returned from yield
123
- block_calls << ::RBS::Test::ArgumentsReturn.return(
124
- arguments: block_args,
125
- value: block_result
126
- )
127
- when exn
128
- # Exception
129
- block_calls << ::RBS::Test::ArgumentsReturn.exception(
130
- arguments: block_args,
131
- exception: exn
132
- )
133
- else
134
- # break?
135
- block_calls << ::RBS::Test::ArgumentsReturn.break(
136
- arguments: block_args
137
- )
101
+ wrapped_block = Object.new.instance_exec do
102
+ new_object = self
103
+
104
+ proc do |*block_args, &block2|
105
+ return_from_block = false
106
+
107
+ begin
108
+ block_result = if self.equal?(new_object)
109
+ if block_receives_block
110
+ #{block_param}.call(*block_args, &block2)
111
+ else
112
+ yield(*block_args)
113
+ end
114
+ else
115
+ # Detected that `self` inside `proc` is not equal to the `self` outside block (which is saved to `new_object`).
116
+ # This means that the block is called with `instance_exec` or `instance_eval`.
117
+ self.instance_exec(*block_args, &#{block_param})
118
+ end
119
+
120
+ return_from_block = true
121
+ ensure
122
+ exn = $!
123
+
124
+ case
125
+ when return_from_block
126
+ # Returned from yield
127
+ block_calls << ::RBS::Test::ArgumentsReturn.return(
128
+ arguments: block_args,
129
+ value: block_result
130
+ )
131
+ when exn
132
+ # Exception
133
+ block_calls << ::RBS::Test::ArgumentsReturn.exception(
134
+ arguments: block_args,
135
+ exception: exn
136
+ )
137
+ else
138
+ # break?
139
+ block_calls << ::RBS::Test::ArgumentsReturn.break(
140
+ arguments: block_args
141
+ )
142
+ end
138
143
  end
139
- end
140
144
 
141
- block_result
142
- end.ruby2_keywords
145
+ block_result
146
+ end.ruby2_keywords
147
+ end
143
148
 
144
149
  result = __send__(:"#{without_name}", *args, &wrapped_block)
145
150
  else
data/lib/rbs/types.rb CHANGED
@@ -1221,6 +1221,12 @@ module RBS
1221
1221
  end
1222
1222
  end
1223
1223
 
1224
+ def map_type_name(&block)
1225
+ UntypedFunction.new(
1226
+ return_type: return_type.map_type_name(&block)
1227
+ )
1228
+ end
1229
+
1224
1230
  def each_type(&block)
1225
1231
  if block
1226
1232
  yield return_type
data/lib/rbs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RBS
4
- VERSION = "3.6.0"
4
+ VERSION = "3.7.0.dev.1"
5
5
  end
data/rbs.gemspec CHANGED
@@ -40,6 +40,6 @@ Gem::Specification.new do |spec|
40
40
  spec.bindir = "exe"
41
41
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
42
42
  spec.require_paths = ["lib"]
43
- spec.required_ruby_version = ">= 3.0"
43
+ spec.required_ruby_version = ">= 3.1"
44
44
  spec.add_dependency "logger"
45
45
  end
data/sig/definition.rbs CHANGED
@@ -21,11 +21,18 @@ module RBS
21
21
  attr_reader defined_in: TypeName
22
22
  attr_reader implemented_in: TypeName?
23
23
 
24
- def initialize: (type: MethodType, member: method_member, defined_in: TypeName, implemented_in: TypeName?) -> void
24
+ # Annotations given to `#member`
25
+ attr_reader member_annotations: Array[AST::Annotation]
25
26
 
26
- def comment: () -> AST::Comment?
27
+ # Annotations given to the overload associated to the method type
28
+ attr_reader overload_annotations: Array[AST::Annotation]
29
+
30
+ # Concatnation of `member_annotations` and `overload_annotations`
31
+ attr_reader annotations: Array[AST::Annotation]
27
32
 
28
- def annotations: () -> Array[AST::Annotation]
33
+ def initialize: (type: MethodType, member: method_member, defined_in: TypeName, implemented_in: TypeName?, ?overload_annotations: Array[AST::Annotation]) -> void
34
+
35
+ def comment: () -> AST::Comment?
29
36
 
30
37
  def update: (?type: MethodType, ?member: method_member, ?defined_in: TypeName, ?implemented_in: TypeName?) -> TypeDef
31
38
 
@@ -35,15 +42,23 @@ module RBS
35
42
  attr_reader super_method: Method?
36
43
  attr_reader defs: Array[TypeDef]
37
44
  attr_reader accessibility: accessibility
38
- attr_reader extra_annotations: Array[AST::Annotation]
45
+
39
46
  attr_reader defined_in: TypeName?
40
47
  attr_reader implemented_in: TypeName?
41
48
  attr_reader method_types: Array[MethodType]
42
49
  attr_reader comments: Array[AST::Comment]
43
- attr_reader annotations: Array[AST::Annotation]
50
+
44
51
  attr_reader members: Array[method_member]
45
52
  attr_reader alias_of: Method?
46
53
 
54
+ # Unused, always returns empty array
55
+ attr_reader extra_annotations: Array[AST::Annotation]
56
+
57
+ # Union of annotations given to `defs`, not contains annotations given to each overload
58
+ attr_reader annotations: Array[AST::Annotation]
59
+
60
+ # Note that the annotations given through `annotations:` keyword is ignored.
61
+ #
47
62
  def initialize: (super_method: Method?,
48
63
  defs: Array[TypeDef],
49
64
  accessibility: accessibility,
@@ -360,7 +360,7 @@ class CGI
360
360
  # -->
361
361
  # Return the accept character set for all new CGI instances.
362
362
  #
363
- def self.accept_charset: () -> String
363
+ def self.accept_charset: () -> encoding
364
364
 
365
365
  # <!--
366
366
  # rdoc-file=lib/cgi/core.rb
@@ -368,7 +368,7 @@ class CGI
368
368
  # -->
369
369
  # Set the accept character set for all new CGI instances.
370
370
  #
371
- def self.accept_charset=: (String accept_charset) -> String
371
+ def self.accept_charset=: (encoding accept_charset) -> encoding
372
372
 
373
373
  # <!--
374
374
  # rdoc-file=lib/cgi/core.rb
@@ -385,7 +385,7 @@ class CGI
385
385
  # <!-- rdoc-file=lib/cgi/core.rb -->
386
386
  # Return the accept character set for this CGI instance.
387
387
  #
388
- attr_reader accept_charset: String
388
+ attr_reader accept_charset: encoding
389
389
 
390
390
  # <!-- rdoc-file=lib/cgi/core.rb -->
391
391
  # This method is an alias for #http_header, when HTML5 tag maker is inactive.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0.dev.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-30 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -525,14 +525,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
525
525
  requirements:
526
526
  - - ">="
527
527
  - !ruby/object:Gem::Version
528
- version: '3.0'
528
+ version: '3.1'
529
529
  required_rubygems_version: !ruby/object:Gem::Requirement
530
530
  requirements:
531
531
  - - ">="
532
532
  - !ruby/object:Gem::Version
533
533
  version: '0'
534
534
  requirements: []
535
- rubygems_version: 3.5.17
535
+ rubygems_version: 3.5.23
536
536
  signing_key:
537
537
  specification_version: 4
538
538
  summary: Type signature for Ruby.