Commit 4a0d0e11

4a0d0e1104ddMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 5 files · +3 added · ~2 modified

Description

DCE uncalled synthetic module class methods (fixes #1062 regression)

96b21e6 (named module_function support) made module_function :foo register foo as a real synthetic module class method (Mod_cls_foo in @meth_*), which is what lets Strings::ANSI.sanitize resolve (#1034). But those synthetic methods, unlike def self.x cls-methods and instance methods, had no liveness gate: an uncalled library module function (e.g. brass's Kernel#fail!) was now analyzed and emitted, surfacing "cannot resolve ... on int" warnings for code that never runs — 160 gems went clean→rejected on the corpus probe. At a03bb49 those methods weren't registered at all (dead), hence silent.

Add transitive reachability for synthetic module class methods, mirroring the existing cls-cmeth/instance DCE: seed from top-level code + implicitly-dispatched names, propagate through reachable method bodies (not into def bodies during the seed walk; default-param values are collected conservatively), and stub any Mod_cls_<name> whose bare name is unreachable. Declaration-modifier symbol args (module_function :foo, private :foo) are not counted as calls, so a method referenced only by its own module_function declaration is correctly dead. A called module function (sanitize) stays live.

brass's fail!/assert/refute (uncalled, chained) are now dead-stubbed — no warnings — matching a03bb49, while #1034 keeps working. optcarrot's dead set is empty (no false-stubbing); bootstrap fixpoint holds.

Fixes #1062

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
4a0d0e1104dd
Parent
b9e10e60c0f8

brass-1.3.0.gemaddedView file

Binary summary diff

@@ -1,0 +1,7 @@
+Format guess: Binary data
+Size: 9.0 KB
+Magic bytes: 6D 65 74 61 64 61 74 61 2E 67 7A 00 00 00 00 00
+CRC32: 429e22eb
+Entropy: 6.25 bits/byte
+NUL bytes: 3001
+String hints: metadata.gz, 0000444, 0000000, 0000000, 00000001264, 02263773600, 013446, ustar, 00wheel, wheel, 0000000, 0000000