rigortype 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/data/builtins/ruby_core/io.yml +1 -0
  4. data/data/builtins/ruby_core/proc.yml +4 -0
  5. data/data/builtins/ruby_core/random.yml +4 -0
  6. data/data/builtins/ruby_core/struct.yml +3 -0
  7. data/data/core_overlay/env.rbs +34 -0
  8. data/data/core_overlay/gc.rbs +50 -0
  9. data/data/core_overlay/hash.rbs +45 -0
  10. data/data/core_overlay/integer.rbs +31 -0
  11. data/data/core_overlay/io_buffer.rbs +27 -0
  12. data/data/core_overlay/kernel.rbs +40 -0
  13. data/data/core_overlay/match_data.rbs +28 -0
  14. data/data/core_overlay/module.rbs +51 -0
  15. data/data/core_overlay/object_space.rbs +29 -0
  16. data/data/core_overlay/proc.rbs +45 -0
  17. data/data/core_overlay/range.rbs +40 -0
  18. data/data/core_overlay/source_range.rbs +78 -0
  19. data/data/core_overlay/string.rbs +86 -0
  20. data/data/vendored_gem_sigs/prime/integer-extension.rbs +41 -0
  21. data/data/vendored_gem_sigs/prime/prime.rbs +372 -0
  22. data/docs/handbook/01-getting-started.md +3 -3
  23. data/docs/handbook/06-classes.md +3 -1
  24. data/docs/handbook/11-sig-gen.md +6 -0
  25. data/docs/handbook/appendix-liskov.md +5 -0
  26. data/docs/manual/03-configuration.md +1 -1
  27. data/docs/manual/04-diagnostics.md +2 -1
  28. data/docs/manual/06-baseline.md +2 -0
  29. data/docs/manual/07-plugins.md +1 -1
  30. data/docs/manual/18-removing-dead-code.md +32 -2
  31. data/docs/manual/plugins/README.md +6 -1
  32. data/docs/manual/plugins/rigor-activerecord.md +21 -0
  33. data/docs/manual/plugins/rigor-alba.md +60 -0
  34. data/docs/manual/plugins/rigor-minitest.md +22 -4
  35. data/docs/manual/plugins/rigor-typelizer.md +71 -0
  36. data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +27 -3
  37. data/lib/rigor/analysis/check_rules/lexical_method_sites.rb +21 -92
  38. data/lib/rigor/analysis/check_rules/ruby_deprecations.rb +275 -0
  39. data/lib/rigor/analysis/check_rules/rule_ids.rb +4 -0
  40. data/lib/rigor/analysis/check_rules/source_arity.rb +21 -2
  41. data/lib/rigor/analysis/check_rules.rb +289 -57
  42. data/lib/rigor/analysis/dependency_recorder.rb +15 -0
  43. data/lib/rigor/analysis/dependency_source_inference/builder.rb +8 -1
  44. data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +21 -0
  45. data/lib/rigor/analysis/dependency_source_inference/index.rb +36 -11
  46. data/lib/rigor/analysis/dependency_source_inference/walker.rb +196 -27
  47. data/lib/rigor/analysis/erb_template_detector.rb +2 -1
  48. data/lib/rigor/analysis/incremental.rb +29 -9
  49. data/lib/rigor/analysis/incremental_run_slot/write_guard.rb +30 -5
  50. data/lib/rigor/analysis/incremental_run_slot.rb +3 -1
  51. data/lib/rigor/analysis/incremental_session.rb +14 -1
  52. data/lib/rigor/analysis/reachability/graph.rb +123 -23
  53. data/lib/rigor/analysis/reachability/scan.rb +290 -36
  54. data/lib/rigor/analysis/rule_catalog.rb +43 -0
  55. data/lib/rigor/analysis/run_cache_key.rb +16 -1
  56. data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +87 -5
  57. data/lib/rigor/analysis/runner/pool_coordinator.rb +50 -11
  58. data/lib/rigor/analysis/runner/run_snapshots.rb +6 -1
  59. data/lib/rigor/analysis/runner.rb +34 -3
  60. data/lib/rigor/analysis/worker_session.rb +7 -4
  61. data/lib/rigor/cache/incremental_snapshot.rb +22 -0
  62. data/lib/rigor/cli/annotate_command.rb +5 -0
  63. data/lib/rigor/cli/baseline_command.rb +7 -18
  64. data/lib/rigor/cli/check_command.rb +2 -1
  65. data/lib/rigor/cli/trace_command.rb +5 -0
  66. data/lib/rigor/cli/type_of_command.rb +5 -3
  67. data/lib/rigor/cli/unused_command.rb +13 -7
  68. data/lib/rigor/cli.rb +10 -2
  69. data/lib/rigor/configuration/severity_profile.rb +6 -0
  70. data/lib/rigor/configuration.rb +46 -2
  71. data/lib/rigor/environment/gated_signature_guard.rb +43 -0
  72. data/lib/rigor/environment/gated_signature_plan.rb +339 -0
  73. data/lib/rigor/environment/rbs_coverage_report.rb +1 -1
  74. data/lib/rigor/environment/rbs_loader.rb +283 -14
  75. data/lib/rigor/environment/required_features.rb +206 -0
  76. data/lib/rigor/environment.rb +21 -3
  77. data/lib/rigor/inference/acceptance.rb +28 -3
  78. data/lib/rigor/inference/builtins/cruby_definers.rb +61 -0
  79. data/lib/rigor/inference/builtins/method_catalog.rb +3 -0
  80. data/lib/rigor/inference/def_node_resolver.rb +23 -1
  81. data/lib/rigor/inference/expression_typer.rb +215 -16
  82. data/lib/rigor/inference/global_write_census.rb +7 -4
  83. data/lib/rigor/inference/guard_rebinding.rb +1 -1
  84. data/lib/rigor/inference/in_effect_refinements/proc_literals.rb +83 -0
  85. data/lib/rigor/inference/in_effect_refinements/refine_defs.rb +54 -0
  86. data/lib/rigor/inference/in_effect_refinements/scope_reads.rb +282 -0
  87. data/lib/rigor/inference/in_effect_refinements/walk.rb +276 -0
  88. data/lib/rigor/inference/in_effect_refinements.rb +256 -0
  89. data/lib/rigor/inference/key_presence_guard/scan.rb +281 -0
  90. data/lib/rigor/inference/key_presence_guard.rb +303 -0
  91. data/lib/rigor/inference/macro_block_self_type.rb +59 -12
  92. data/lib/rigor/inference/method_dispatcher/alias_strict_nominals.rb +36 -0
  93. data/lib/rigor/inference/method_dispatcher/arithmetic_sequence_elements.rb +73 -0
  94. data/lib/rigor/inference/method_dispatcher/imprecise_argument.rb +68 -0
  95. data/lib/rigor/inference/method_dispatcher/integer_step_block_params.rb +81 -0
  96. data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +6 -0
  97. data/lib/rigor/inference/method_dispatcher/keyword_arguments.rb +267 -0
  98. data/lib/rigor/inference/method_dispatcher/method_folding.rb +2 -1
  99. data/lib/rigor/inference/method_dispatcher/overload_selector.rb +122 -105
  100. data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +259 -28
  101. data/lib/rigor/inference/method_dispatcher/splat_arity.rb +71 -0
  102. data/lib/rigor/inference/method_dispatcher.rb +44 -11
  103. data/lib/rigor/inference/module_function_state.rb +2 -1
  104. data/lib/rigor/inference/narrowing.rb +20 -6
  105. data/lib/rigor/inference/object_mixins.rb +180 -0
  106. data/lib/rigor/inference/project_patched_methods.rb +10 -5
  107. data/lib/rigor/inference/project_patched_scanner.rb +71 -3
  108. data/lib/rigor/inference/refine_census.rb +239 -0
  109. data/lib/rigor/inference/refine_self.rb +317 -0
  110. data/lib/rigor/inference/refined_dispatch/own_method.rb +403 -0
  111. data/lib/rigor/inference/refined_dispatch.rb +272 -0
  112. data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +13 -0
  113. data/lib/rigor/inference/scope_indexer.rb +687 -60
  114. data/lib/rigor/inference/statement_evaluator.rb +71 -20
  115. data/lib/rigor/inference/string_mutation.rb +9 -3
  116. data/lib/rigor/inference/synthetic_method_scanner.rb +2 -1
  117. data/lib/rigor/inference/version_guard.rb +19 -10
  118. data/lib/rigor/language_server/project_context.rb +31 -0
  119. data/lib/rigor/language_server/server.rb +18 -0
  120. data/lib/rigor/plugin/inflector.rb +1 -1
  121. data/lib/rigor/plugin/io_boundary.rb +42 -3
  122. data/lib/rigor/plugin/macro/block_as_method.rb +51 -8
  123. data/lib/rigor/project_environment.rb +29 -6
  124. data/lib/rigor/protection/mutation_cache.rb +1 -1
  125. data/lib/rigor/protection/mutator.rb +1 -1
  126. data/lib/rigor/reflection/constant_ancestors.rb +127 -11
  127. data/lib/rigor/reflection/constant_path.rb +13 -2
  128. data/lib/rigor/reflection.rb +40 -8
  129. data/lib/rigor/scope/discovery_index.rb +40 -1
  130. data/lib/rigor/scope/resolution_chain.rb +159 -11
  131. data/lib/rigor/scope.rb +189 -10
  132. data/lib/rigor/sig_gen/classification.rb +4 -1
  133. data/lib/rigor/sig_gen/generator.rb +55 -5
  134. data/lib/rigor/sig_gen/method_candidate.rb +2 -2
  135. data/lib/rigor/sig_gen/skip_reason_catalog.rb +12 -0
  136. data/lib/rigor/source/alias_names.rb +52 -0
  137. data/lib/rigor/source/literals.rb +3 -2
  138. data/lib/rigor/source/symbol_name.rb +20 -0
  139. data/lib/rigor/type/combinator.rb +34 -2
  140. data/lib/rigor/type/float_range.rb +4 -1
  141. data/lib/rigor/type/nominal.rb +6 -1
  142. data/lib/rigor/version.rb +1 -1
  143. data/plugins/rigor-ac-library-rb/lib/rigor/plugin/ac_library_rb.rb +28 -0
  144. data/plugins/rigor-ac-library-rb/lib/rigor-ac-library-rb.rb +3 -0
  145. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/convolution.rbs +7 -0
  146. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/data_structures.rbs +160 -0
  147. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/graph.rbs +94 -0
  148. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/math.rbs +42 -0
  149. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/modint.rbs +71 -0
  150. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/object.rbs +37 -0
  151. data/plugins/rigor-ac-library-rb/sig/ac_library_rb/segtree.rbs +83 -0
  152. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/analyzer.rb +2 -1
  153. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/association_roots.rb +100 -0
  154. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +94 -10
  155. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +43 -2
  156. data/plugins/rigor-activerecord/sig/active_record/relation.rbs +3 -1
  157. data/plugins/rigor-alba/lib/rigor/plugin/alba/resource_collector.rb +149 -0
  158. data/plugins/rigor-alba/lib/rigor/plugin/alba/resource_discoverer.rb +74 -0
  159. data/plugins/rigor-alba/lib/rigor/plugin/alba/resource_index.rb +104 -0
  160. data/plugins/rigor-alba/lib/rigor/plugin/alba.rb +85 -0
  161. data/plugins/rigor-alba/lib/rigor-alba.rb +3 -0
  162. data/plugins/rigor-alba/sig/alba.rbs +4 -0
  163. data/plugins/rigor-ffi/lib/rigor/plugin/ffi/analyzer.rb +2 -2
  164. data/plugins/rigor-ffi/lib/rigor/plugin/ffi/target_detector.rb +29 -12
  165. data/plugins/rigor-ffi/lib/rigor/plugin/ffi.rb +7 -6
  166. data/plugins/rigor-minitest/lib/rigor/plugin/minitest/assertion_analyzer.rb +130 -21
  167. data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +6 -4
  168. data/plugins/rigor-pundit/lib/rigor/plugin/pundit/analyzer.rb +4 -4
  169. data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +1 -1
  170. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +1 -1
  171. data/plugins/rigor-rbs-inline/lib/rigor/plugin/rbs_inline.rb +31 -0
  172. data/plugins/rigor-typelizer/lib/rigor/plugin/typelizer/serializer_collector.rb +102 -0
  173. data/plugins/rigor-typelizer/lib/rigor/plugin/typelizer/serializer_discoverer.rb +87 -0
  174. data/plugins/rigor-typelizer/lib/rigor/plugin/typelizer/serializer_index.rb +76 -0
  175. data/plugins/rigor-typelizer/lib/rigor/plugin/typelizer.rb +73 -0
  176. data/plugins/rigor-typelizer/lib/rigor-typelizer.rb +3 -0
  177. data/sig/rigor/analysis/dependency_source_inference/index.rbs +1 -1
  178. data/sig/rigor/plugin/io_boundary.rbs +3 -0
  179. data/sig/rigor/scope.rbs +27 -4
  180. data/sig/rigor/source.rbs +4 -0
  181. data/sig/rigor.rbs +3 -1
  182. metadata +66 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c26e2df607ebe3e1ef3b0c34a329aea4b1b0c80ec311cf6d9a83c4a58a358dfa
4
- data.tar.gz: 2c4097594c8abe73819197a867cbb9a7b7dc3de86d8a2f22a2a83b1f948fa63a
3
+ metadata.gz: a812e377e347e70448e42c33e6f4fe79152d40851b999609e9e5fdd98dc5a5a0
4
+ data.tar.gz: 285b195c8058fa30063c5ad40ac6718cd59a3f1d79bb79ccac32184093dba5b0
5
5
  SHA512:
6
- metadata.gz: d790e8fdb333983f82d85fb13036661ef87ca82d273b86955e1c7fa3191a65d027a04ea92fb4877edeb24f3df6bdae4dc03780791a79b15510ea5c7b494f23b6
7
- data.tar.gz: b1258c842c5e656aea59b32eb91310cdda72a9dade402c87d2523bae3e4fa927f6607b0e2acd4250d24bfcba77e27df778aaf02c50c57300b6c27099c312c098
6
+ metadata.gz: 148890acd58affcbc6eb81afe948d882cf254930ff7ad83635592a065bf038de149865891767318721bdc103e7def6e4c71686b8d40a8ff9b55034c446cf8d32
7
+ data.tar.gz: e6d458ec387e004c83b8751e5381eda53ec5979433580263ea1586cbb574245875f50a94fce86540badae485d08d20ff73c7e3aea4d80d33c4226af3a4b7f584
data/README.md CHANGED
@@ -232,7 +232,7 @@ rigor docs --list # list every bundled page
232
232
 
233
233
  ## Status
234
234
 
235
- Current release: **`v0.4.1`** (2026-10-08) — on the
235
+ Current release: **`v0.4.2`** (2026-10-11) — on the
236
236
  `0.4.x` line, continuing the evaluation era opened by `v0.2.0`, the first
237
237
  publicly-announced (general / evaluation) release. The line publishes
238
238
  an enumerated [compatibility surface](docs/compatibility.md) as a
@@ -1606,3 +1606,4 @@ classes:
1606
1606
  purity: leaf
1607
1607
  singleton_methods: {}
1608
1608
  undefined: []
1609
+ rdoc_only: true
@@ -42,6 +42,7 @@ classes:
42
42
  rbs:
43
43
  - "(?) -> untyped"
44
44
  rbs_at: references/rbs/core/proc.rbs:624
45
+ rdoc_only: true
45
46
  "[]":
46
47
  source: c
47
48
  cfunc: proc_call
@@ -50,6 +51,7 @@ classes:
50
51
  c_body_at: references/ruby/proc.c:1104
51
52
  c_effects: []
52
53
  purity: leaf
54
+ rdoc_only: true
53
55
  "===":
54
56
  source: c
55
57
  cfunc: proc_call
@@ -58,6 +60,7 @@ classes:
58
60
  c_body_at: references/ruby/proc.c:1104
59
61
  c_effects: []
60
62
  purity: leaf
63
+ rdoc_only: true
61
64
  yield:
62
65
  source: c
63
66
  cfunc: proc_call
@@ -66,6 +69,7 @@ classes:
66
69
  c_body_at: references/ruby/proc.c:1104
67
70
  c_effects: []
68
71
  purity: leaf
72
+ rdoc_only: true
69
73
  to_proc:
70
74
  source: c
71
75
  cfunc: proc_to_proc
@@ -63,6 +63,7 @@ classes:
63
63
  rbs:
64
64
  - "(?Integer seed) -> void"
65
65
  rbs_at: references/rbs/core/random.rbs:36
66
+ rdoc_only: true
66
67
  rand:
67
68
  source: c
68
69
  cfunc: random_rand
@@ -71,6 +72,7 @@ classes:
71
72
  c_body_at: references/ruby/random.c:1574
72
73
  c_effects: []
73
74
  purity: leaf
75
+ rdoc_only: true
74
76
  bytes:
75
77
  source: c
76
78
  cfunc: random_bytes
@@ -80,6 +82,7 @@ classes:
80
82
  c_effects:
81
83
  - dispatch
82
84
  purity: dispatch
85
+ rdoc_only: true
83
86
  seed:
84
87
  source: c
85
88
  cfunc: random_get_seed
@@ -91,6 +94,7 @@ classes:
91
94
  rbs:
92
95
  - "() -> Integer"
93
96
  rbs_at: references/rbs/core/random.rbs:172
97
+ rdoc_only: true
94
98
  singleton_methods:
95
99
  srand:
96
100
  source: c
@@ -303,6 +303,7 @@ classes:
303
303
  rbs:
304
304
  - "() -> bool?"
305
305
  rbs_at: references/rbs/core/struct.rbs:267
306
+ rdoc_only: true
306
307
  members:
307
308
  source: c
308
309
  cfunc: rb_struct_s_members_m
@@ -314,6 +315,7 @@ classes:
314
315
  rbs:
315
316
  - "() -> Array[Symbol]"
316
317
  rbs_at: references/rbs/core/struct.rbs:250
318
+ rdoc_only: true
317
319
  undefined: []
318
320
  Data:
319
321
  parent: Object
@@ -441,5 +443,6 @@ classes:
441
443
  c_body_at: references/ruby/struct.c:207
442
444
  c_effects: []
443
445
  purity: leaf
446
+ rdoc_only: true
444
447
  undefined:
445
448
  - new
@@ -0,0 +1,34 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- ENV.fetch_values (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds `ENV.fetch_values` (`hash.c`, call-seq
6
+ # `ENV.fetch_values(*names) -> array of values` and
7
+ # `ENV.fetch_values(*names) {|name| ... } -> array of values`), mirroring
8
+ # `Hash#fetch_values`. No rbs release through 4.2 declares it on
9
+ # `RBS::Unnamed::ENVClass`, the class rbs gives the `ENV` object, so correct
10
+ # 4.1 code reported `call.undefined-method`. The name and value types follow
11
+ # that class's own `fetch`.
12
+ #
13
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
14
+ # the method upstream.
15
+ #
16
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
17
+ # alternatives; false positives outrank), and on a module the class
18
+ # includes so that a later direct declaration overrides it instead of
19
+ # raising `DuplicatedMethodDefinitionError` for the whole class (see
20
+ # `process.rbs`).
21
+ module RigorCoreOverlay
22
+ module Ruby41EnvFetchValues
23
+ def fetch_values: (*String names) -> Array[String]
24
+ | [X] (*String names) { (String name) -> X } -> Array[String | X]
25
+ end
26
+ end
27
+
28
+ module RBS
29
+ module Unnamed
30
+ class ENVClass
31
+ include RigorCoreOverlay::Ruby41EnvFetchValues
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,50 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- GC.start / GC#garbage_collect `global:` and GC.stat `scope:` (Ruby 4.1) ---
4
+ #
5
+ # Issue #1718. Ruby 4.1's `gc.rb` adds a `global:` keyword to the collection
6
+ # entry points and a `scope:` keyword to `GC.stat`:
7
+ #
8
+ # def self.start full_mark: true, immediate_mark: true, immediate_sweep: true, global: true
9
+ # def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true, global: true
10
+ # def self.stat hash_or_key = nil, scope: :ractor
11
+ #
12
+ # `scope:` is `:ractor`, `:local` or `:global` and raises `ArgumentError`
13
+ # otherwise; it is declared `Symbol` so that a scope held in a variable is
14
+ # not reported. No rbs release through 4.2 declares either keyword. Rigor
15
+ # does not check keyword names today, so these entries make the signatures
16
+ # correct for when it does.
17
+ # `ObjectSpace.garbage_collect` takes `global:` too (`object_space.rbs`).
18
+ #
19
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
20
+ # the keywords upstream.
21
+ #
22
+ # `GC.stat` with `scope:` has one arm per form, each answering what the
23
+ # upstream arm of that form does. The overload selector matches a call's
24
+ # keyword hash against an overload's keywords (#1727), so
25
+ # `GC.stat(:count, scope: :global)` takes the `Integer` arm and
26
+ # `GC.stat({}, scope: :global)` the `Hash` one.
27
+ #
28
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
29
+ # alternatives; false positives outrank). Each entry is an `| ...`
30
+ # continuation of the upstream declaration, which every supported rbs
31
+ # release carries; a later release that declares the keyword only repeats
32
+ # an overload. `global:` is optional in its arm: the upstream arms take no
33
+ # positional argument and answer the same type, so the arm changes no
34
+ # selected return, and an arm with a REQUIRED keyword would switch
35
+ # `call.wrong-arity` off for the whole method (`compute_arity_envelope`
36
+ # declines any method with one), losing `GC.start(1)`. `GC.stat`'s `scope:`
37
+ # arm does require its keyword, so that a call without it still selects
38
+ # the upstream `(Symbol) -> Integer` / `(?Hash) -> Hash` arms; the cost is
39
+ # that `GC.stat` is not arity-checked.
40
+ module GC
41
+ def self.start: (?immediate_sweep: boolish, ?immediate_mark: boolish, ?full_mark: boolish, ?global: boolish) -> nil
42
+ | ...
43
+
44
+ def self.stat: (Symbol key, scope: Symbol) -> Integer
45
+ | (?Hash[Symbol, untyped]? hash, scope: Symbol) -> Hash[Symbol, untyped]
46
+ | ...
47
+
48
+ def garbage_collect: (?immediate_sweep: boolish, ?immediate_mark: boolish, ?full_mark: boolish, ?global: boolish) -> nil
49
+ | ...
50
+ end
@@ -0,0 +1,45 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Hash.ruby2_keywords_hash? / Hash.ruby2_keywords_hash ---
4
+ #
5
+ # CRuby's `hash.c` defines both as singleton methods of `Hash`, present since
6
+ # Ruby 2.7:
7
+ #
8
+ # rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash?", rb_hash_s_ruby2_keywords_hash_p, 1);
9
+ # rb_define_singleton_method(rb_cHash, "ruby2_keywords_hash", rb_hash_s_ruby2_keywords_hash, 1);
10
+ #
11
+ # `ruby2_keywords_hash?` answers whether the argument is a hash flagged by
12
+ # `ruby2_keywords`; `ruby2_keywords_hash` returns a copy of its argument with
13
+ # that flag set. Upstream `ruby/rbs` declares neither through 4.2, so
14
+ #
15
+ # Hash.ruby2_keywords_hash?({})
16
+ #
17
+ # reported `call.undefined-method` on correct code. Ruby 4.1 deprecates both
18
+ # (Feature #22205) and removes them in 4.5; `call.deprecated-ruby2-keywords`
19
+ # reports the deprecation under an explicit `target_ruby` of 4.1 or later.
20
+ #
21
+ # The return of `ruby2_keywords_hash` is the argument's own Hash type: the
22
+ # copy has the same keys and values, and the flag does not show in the type.
23
+ #
24
+ # Declared on a module `Hash` extends, not with `def self.…`, for the reason
25
+ # `process.rbs` gives: a project `sig/` or a later rbs release may declare
26
+ # either method directly, and a second direct `def` is a
27
+ # `DuplicatedMethodDefinitionError` that takes `Hash`'s whole singleton surface
28
+ # down to `Dynamic[top]`. A direct `def` overrides a method `Hash` gets through
29
+ # `extend`, so the overlay stands down instead of colliding.
30
+ #
31
+ # Unconditional, not gated on `target_ruby` or the rbs line: both methods exist
32
+ # on every supported Ruby (2.7 through 4.4), and gating would report
33
+ # `call.undefined-method` on a correct project still on the default
34
+ # `target_ruby`. The deprecation for 4.1+ is a separate rule and does not read
35
+ # this declaration.
36
+ module RigorCoreOverlay
37
+ module HashRuby2Keywords
38
+ def ruby2_keywords_hash?: (Hash[untyped, untyped] hash) -> bool
39
+ def ruby2_keywords_hash: [K, V] (Hash[K, V] hash) -> Hash[K, V]
40
+ end
41
+ end
42
+
43
+ class Hash[unchecked out K, unchecked out V]
44
+ extend RigorCoreOverlay::HashRuby2Keywords
45
+ end
@@ -0,0 +1,31 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Integer#bit_count (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds `Integer#bit_count`, the population count of
6
+ # the receiver's binary representation (`numeric.c`, call-seq
7
+ # `bit_count -> integer`). No rbs release through 4.2 declares it, so
8
+ # `5.bit_count` reported `call.undefined-method` on correct 4.1 code.
9
+ #
10
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
11
+ # the method upstream.
12
+ #
13
+ # Declared unconditionally, not gated on `target_ruby`: a 4.0-targeted
14
+ # project calling it is an error Rigor then misses, but gating would report
15
+ # every correct 4.1 call under the default target (ADR-121 § Rejected
16
+ # alternatives; false positives outrank).
17
+ #
18
+ # Declared on a module `Integer` includes, not as a direct `def`: a second
19
+ # direct `def` from a later rbs or a project `sig/` is a
20
+ # `DuplicatedMethodDefinitionError` that takes all of `Integer` down to
21
+ # `Dynamic[top]`, while a direct `def` from either source simply overrides
22
+ # a method the class gets through `include` (see `process.rbs`).
23
+ module RigorCoreOverlay
24
+ module Ruby41Integer
25
+ def bit_count: () -> Integer
26
+ end
27
+ end
28
+
29
+ class Integer
30
+ include RigorCoreOverlay::Ruby41Integer
31
+ end
@@ -0,0 +1,27 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- IO::Buffer#bit_count (Ruby 4.1) ---
4
+ #
5
+ # Issue #1718. Ruby 4.1 adds `IO::Buffer#bit_count` (`io_buffer.c`, call-seq
6
+ # `bit_count([offset, [length]]) -> integer`), the population count of the
7
+ # buffer or of a subrange. Either argument may be `nil` for its default
8
+ # (`io_buffer_extract_offset_length`). No rbs release through 4.2 declares
9
+ # it, so correct 4.1 code reported `call.undefined-method`.
10
+ #
11
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
12
+ # the method upstream.
13
+ #
14
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
15
+ # alternatives; false positives outrank), and on a module `IO::Buffer`
16
+ # includes so that a later direct declaration overrides it instead of
17
+ # raising `DuplicatedMethodDefinitionError` for the whole class (see
18
+ # `process.rbs`).
19
+ module RigorCoreOverlay
20
+ module Ruby41IOBuffer
21
+ def bit_count: (?Integer? offset, ?Integer? length) -> Integer
22
+ end
23
+ end
24
+
25
+ class IO::Buffer
26
+ include RigorCoreOverlay::Ruby41IOBuffer
27
+ end
@@ -0,0 +1,40 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Kernel#autoload_relative (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds the global function `autoload_relative`
6
+ # (`load.c`, call-seq `autoload_relative(const, filename) -> nil`), the
7
+ # top-level counterpart of `Module#autoload_relative` (`module.rbs`). No rbs
8
+ # release through 4.2 declares it, so a top-level call reported
9
+ # `call.undefined-method` on correct 4.1 code.
10
+ #
11
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
12
+ # the method upstream.
13
+ #
14
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
15
+ # alternatives; false positives outrank). A global function is a private
16
+ # instance method plus a public singleton method on `Kernel` — what rbs
17
+ # spells `def self?.` — so the two halves are declared on two modules,
18
+ # one `Kernel` includes and one it extends. A later direct `def self?.`
19
+ # from rbs or a project `sig/` overrides both instead of raising
20
+ # `DuplicatedMethodDefinitionError` for the whole module (see
21
+ # `process.rbs`). The included module's self type is `BasicObject`: the
22
+ # default, `Object`, includes `Kernel` itself, and that cycle is a
23
+ # `RecursiveAncestorError` that takes `Object` and every class under it
24
+ # down to `Dynamic[top]`.
25
+ module RigorCoreOverlay
26
+ module Ruby41KernelAutoloadRelative : BasicObject
27
+ private
28
+
29
+ def autoload_relative: (Symbol | string const, string | _ToPath filename) -> nil
30
+ end
31
+
32
+ module Ruby41KernelSingletonAutoloadRelative
33
+ def autoload_relative: (Symbol | string const, string | _ToPath filename) -> nil
34
+ end
35
+ end
36
+
37
+ module Kernel
38
+ include RigorCoreOverlay::Ruby41KernelAutoloadRelative
39
+ extend RigorCoreOverlay::Ruby41KernelSingletonAutoloadRelative
40
+ end
@@ -0,0 +1,28 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- MatchData#integer_at (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds `MatchData#integer_at` (`re.c`, call-seq
6
+ # `integer_at(index, base = 10) -> integer or nil` and
7
+ # `integer_at(name, base = 10) -> integer or nil`): `$~.integer_at(N)` is
8
+ # `$N&.to_i`. No rbs release through 4.2 declares it, so correct 4.1 code
9
+ # reported `call.undefined-method`. A non-Integer first argument is read as
10
+ # a group name; `base` goes through `NUM2INT`, hence `int`.
11
+ #
12
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
13
+ # the method upstream.
14
+ #
15
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
16
+ # alternatives; false positives outrank), and on a module `MatchData`
17
+ # includes so that a later direct declaration overrides it instead of
18
+ # raising `DuplicatedMethodDefinitionError` for the whole class (see
19
+ # `process.rbs`).
20
+ module RigorCoreOverlay
21
+ module Ruby41MatchData
22
+ def integer_at: (Integer | String | Symbol index_or_name, ?int base) -> Integer?
23
+ end
24
+ end
25
+
26
+ class MatchData
27
+ include RigorCoreOverlay::Ruby41MatchData
28
+ end
@@ -0,0 +1,51 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Module#descendants, #autoload_relative, method_defined?'s include_all (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds, on `Module`:
6
+ #
7
+ # descendants -> array (class.c)
8
+ # autoload_relative(const, filename) -> nil (load.c)
9
+ # method_defined?(symbol, inherit=true, include_all = false) -> true or false
10
+ # (vm_method.c, Feature #22297)
11
+ #
12
+ # No rbs release through 4.2 declares the first two or the third argument,
13
+ # so correct 4.1 code reported `call.undefined-method` or
14
+ # `call.wrong-arity`. `descendants` answers classes and modules alike,
15
+ # hence `Array[Module]`; on a `Class` it answers only classes, since no
16
+ # module has a class among its ancestors, so `Class` narrows it to
17
+ # `Array[Class]` as rbs's `Class#subclasses` does.
18
+ #
19
+ # TEMPORARY: delete each entry once the rbs release Rigor bundles declares
20
+ # it upstream.
21
+ #
22
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
23
+ # alternatives; false positives outrank). The new methods sit on a module
24
+ # `Module` includes so that a later direct declaration overrides them
25
+ # instead of raising `DuplicatedMethodDefinitionError` for the whole class
26
+ # (see `process.rbs`). The three-argument `method_defined?` is an `| ...`
27
+ # continuation of the upstream declaration, which every supported rbs
28
+ # release carries. `interned` and `path` are spelled out because rbs 3.0-3.2
29
+ # predate both aliases.
30
+ module RigorCoreOverlay
31
+ module Ruby41Module
32
+ def descendants: () -> Array[Module]
33
+
34
+ def autoload_relative: (Symbol | string const, string | _ToPath filename) -> nil
35
+ end
36
+
37
+ module Ruby41ClassDescendants
38
+ def descendants: () -> Array[Class]
39
+ end
40
+ end
41
+
42
+ class Module
43
+ include RigorCoreOverlay::Ruby41Module
44
+
45
+ def method_defined?: (Symbol | string name, boolish inherit, boolish include_all) -> bool
46
+ | ...
47
+ end
48
+
49
+ class Class
50
+ include RigorCoreOverlay::Ruby41ClassDescendants
51
+ end
@@ -0,0 +1,29 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- ObjectSpace.garbage_collect `global:` (Ruby 4.1) ---
4
+ #
5
+ # Issue #1718. Ruby 4.1's `gc.rb` adds the `global:` keyword to
6
+ # `ObjectSpace#garbage_collect` (a `module_function`, so both the singleton
7
+ # and the private instance method), as it does to `GC.start` (`gc.rbs`):
8
+ #
9
+ # def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true, global: true
10
+ #
11
+ # No rbs release through 4.2 declares it. Rigor does not check keyword
12
+ # names today, so this entry makes the signature correct for when it does.
13
+ # The return mirrors upstream's own `void`.
14
+ #
15
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
16
+ # the keyword upstream.
17
+ #
18
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
19
+ # alternatives; false positives outrank), as `| ...` continuations of the
20
+ # upstream declarations. `global:` is optional in the added arm, which then
21
+ # answers every call the upstream arm does with the same type; a required
22
+ # keyword would switch `call.wrong-arity` off for the method (see `gc.rbs`).
23
+ module ObjectSpace
24
+ def self.garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool, ?global: boolish) -> void
25
+ | ...
26
+
27
+ def garbage_collect: (?full_mark: bool, ?immediate_mark: bool, ?immediate_sweep: bool, ?global: boolish) -> void
28
+ | ...
29
+ end
@@ -0,0 +1,45 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Proc#refined (Ruby 4.1) ---
4
+ #
5
+ # Ruby 4.1 adds `Proc#refined(*modules)` (Feature #22097, `proc_refined` in
6
+ # CRuby's `proc.c`): it returns a copy of the receiver whose body runs with
7
+ # the given modules' refinements active. Upstream `ruby/rbs` does not declare
8
+ # it through 4.2, so
9
+ #
10
+ # pr = ->(s) { s.shout }.refined(Shout)
11
+ #
12
+ # reported `call.undefined-method` on correct 4.1 code.
13
+ #
14
+ # The return is `self`, not `Proc`. CRuby builds the copy with
15
+ # `proc_create(rb_obj_class(self), …, is_lambda)` (`vm.c`'s
16
+ # `rb_proc_dup_with_iseq_and_recipe`) and returns the receiver itself when
17
+ # called with no modules, so the class, lambda-ness, `parameters`, `arity`
18
+ # and source location all carry over (`test_refined_preserves_lambda`,
19
+ # `test_refined_preserves_location_and_parameters` in `test/ruby/test_proc.rb`).
20
+ # A refinement changes which methods the body's calls reach, never the
21
+ # Proc's own signature.
22
+ #
23
+ # Not modelled: `refined` raises `ArgumentError` on a Proc not backed by a
24
+ # Ruby block (`:sym.to_proc`, `method(:m).to_proc`), and `TypeError` for a
25
+ # Class argument (`Check_Type(arg, T_MODULE)`), which `*Module` accepts.
26
+ #
27
+ # Unconditional, not gated on `target_ruby >= 4.1` (issue #1665): gating would
28
+ # report `call.undefined-method` on every correct 4.1 project still on the
29
+ # default `target_ruby`. False positives outrank the missed 4.0-target error.
30
+ #
31
+ # Declared on a module `Proc` includes, not with a direct `def`, for the reason
32
+ # `process.rbs` gives: a later rbs release or a project `sig/` is likely to
33
+ # declare `Proc#refined` itself, and a second direct `def` is a
34
+ # `DuplicatedMethodDefinitionError` that takes `Proc`'s whole instance surface
35
+ # down to `Dynamic[top]`. A direct `def` overrides an included module's method,
36
+ # so the overlay stands down instead of colliding.
37
+ module RigorCoreOverlay
38
+ module ProcRefined
39
+ def refined: (*Module) -> self
40
+ end
41
+ end
42
+
43
+ class Proc
44
+ include RigorCoreOverlay::ProcRefined
45
+ end
@@ -0,0 +1,40 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Range#clamp (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds `Range#clamp` (`range.c`, call-seq
6
+ # `clamp(min, max) -> range` / `clamp(range) -> range`), which returns a new
7
+ # range whose ends are clamped to the bounds. No rbs release through 4.2
8
+ # declares it, so `(1..10).clamp(2, 5)` reported `call.undefined-method` on
9
+ # correct 4.1 code.
10
+ #
11
+ # Either bound may be `nil` (unbounded), which leaves that end of the
12
+ # receiver as it is. The first two overloads answer the common case, bounds
13
+ # of the receiver's own element type, as `Range[Elem]`. Bounds of another
14
+ # type (`(1..10).clamp(2.5, nil)`) take the `untyped` arms rather than be
15
+ # reported. Those arms are deliberately not generic: a `[T] (T min, T max)`
16
+ # arm binds `T` to `Float | nil` for a `Float?` bound and puts a `nil` in the
17
+ # result's elements that CRuby never produces, which then reports
18
+ # `call.possible-nil-receiver` on correct code that iterates the result.
19
+ #
20
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
21
+ # the method upstream.
22
+ #
23
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
24
+ # alternatives; false positives outrank), and on a module `Range` includes
25
+ # so that a later direct declaration overrides it instead of raising
26
+ # `DuplicatedMethodDefinitionError` for the whole class (see `process.rbs`).
27
+ # `Elem` is `unchecked` on the module because the first two overloads read it
28
+ # in parameter position.
29
+ module RigorCoreOverlay
30
+ module Ruby41Range[unchecked out Elem]
31
+ def clamp: (Elem? min, Elem? max) -> Range[Elem]
32
+ | (Range[Elem?] range) -> Range[Elem]
33
+ | (untyped min, untyped max) -> Range[untyped]
34
+ | (Range[untyped] range) -> Range[untyped]
35
+ end
36
+ end
37
+
38
+ class Range[out Elem]
39
+ include RigorCoreOverlay::Ruby41Range[Elem]
40
+ end
@@ -0,0 +1,78 @@
1
+ # Rigor core overlay — supplemental core signatures.
2
+ #
3
+ # --- Ruby::SourceRange and the #source_range readers (Ruby 4.1) ---
4
+ #
5
+ # Issue #1691. Ruby 4.1 adds the `Ruby::SourceRange` class (`proc.c`) and
6
+ # four methods that answer one:
7
+ #
8
+ # Thread::Backtrace::Location#source_range -> Ruby::SourceRange (vm_backtrace.c)
9
+ # Proc#source_range, Method#source_range,
10
+ # UnboundMethod#source_range -> Ruby::SourceRange or nil (proc.c)
11
+ #
12
+ # NEWS lists only the backtrace reader; `proc.c` defines the other three
13
+ # alongside the class. They answer `nil` for a proc or method with no Ruby
14
+ # source (a C method, a `Symbol#to_proc`). The class's readers are, per
15
+ # their call-seqs:
16
+ #
17
+ # path -> String absolute_path -> String or nil
18
+ # start_line -> Integer start_column -> Integer
19
+ # end_line -> Integer end_column -> Integer
20
+ #
21
+ # `Ruby::SourceRange` has no allocator (`new` is undefined), so no
22
+ # constructor is declared. No rbs release through 4.2 declares any of
23
+ # this, so correct 4.1 code reported `call.undefined-method`.
24
+ #
25
+ # TEMPORARY: delete this file once the rbs release Rigor bundles declares
26
+ # the methods upstream.
27
+ #
28
+ # Declared unconditionally, not gated on `target_ruby` (ADR-121 § Rejected
29
+ # alternatives; false positives outrank). Every method sits on a module the
30
+ # class includes, so that a later direct declaration from rbs or a project
31
+ # `sig/` overrides it instead of raising `DuplicatedMethodDefinitionError`
32
+ # for the whole class (see `process.rbs`). `Ruby::SourceRange` is declared
33
+ # without a superclass, so a later upstream `< Object` reopening agrees.
34
+ module RigorCoreOverlay
35
+ module Ruby41LocationSourceRange
36
+ def source_range: () -> Ruby::SourceRange
37
+ end
38
+
39
+ module Ruby41CallableSourceRange
40
+ def source_range: () -> Ruby::SourceRange?
41
+ end
42
+
43
+ module Ruby41SourceRange
44
+ def path: () -> String
45
+
46
+ def absolute_path: () -> String?
47
+
48
+ def start_line: () -> Integer
49
+
50
+ def start_column: () -> Integer
51
+
52
+ def end_line: () -> Integer
53
+
54
+ def end_column: () -> Integer
55
+ end
56
+ end
57
+
58
+ class Thread::Backtrace::Location
59
+ include RigorCoreOverlay::Ruby41LocationSourceRange
60
+ end
61
+
62
+ class Proc
63
+ include RigorCoreOverlay::Ruby41CallableSourceRange
64
+ end
65
+
66
+ class Method
67
+ include RigorCoreOverlay::Ruby41CallableSourceRange
68
+ end
69
+
70
+ class UnboundMethod
71
+ include RigorCoreOverlay::Ruby41CallableSourceRange
72
+ end
73
+
74
+ module Ruby
75
+ class SourceRange
76
+ include RigorCoreOverlay::Ruby41SourceRange
77
+ end
78
+ end