Commit 8e5a1a4a

8e5a1a4af890Merged

Ori Pekelman <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

spinel-doctor: add an inference leg (methods widened to untyped)

A method whose signature spinel widened to untyped runs on the boxed poly slow path -- correct, but slower, and often the first visible sign that inference could not pin a concrete type (sometimes the leading edge of a latent type gap). --emit-rbs already marks each such site with a # spinel: widened to untyped (slow path) comment; this leg surfaces them in the one health report instead of requiring a separate --emit-rbs read.

Info severity: it does not affect the exit code (the program is correct), matching requires. Reuses the existing --emit-rbs path; no new compiler surface. --only inference / --skip inference work like the other legs.

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

Details

Commit
8e5a1a4af890
Parent
4058359a8053

tools/doctor.rbmodifiedView file

@@ -7,6 +7,7 @@
77 # build compile to a binary; report compile / codegen / C-build failure
88 # unsupported codegen gaps that degrade to a stub (stderr "unsupported ...")
99 # unresolved calls that silently degrade to nil/0 (SPINEL_WARN_UNRESOLVED)
10+# inference methods spinel widened to untyped (the boxed poly slow path)
1011 # requires non-relative `require`s spinel treats as native / no-op
1112 # behavior (opt) compiled output vs CRuby; needs `ruby` on PATH
1213
@@ -63,7 +64,7 @@
6364 quiet = true
6465 elsif a == "-h" || a == "--help"
6566 puts "usage: spinel-doctor [--only a,b] [--skip a,b] [--behavior] [--quiet] app.rb"
66- puts " legs: build unsupported unresolved requires behavior"
67+ puts " legs: build unsupported unresolved inference requires behavior"
6768 exit(0)
6869 else
6970 src = a
@@ -91,6 +92,24 @@
9192 errs = errs + report("unresolved", "warn", grep_kind(diag, "warning: unresolved"), quiet)
9293 end
9394
95+ if leg_on("inference", only, skip)
96+ # Methods whose signature spinel widened to `untyped` -- the boxed poly
97+ # slow path. Each such site is a "# spinel: widened to untyped (slow path)"
98+ # comment in --emit-rbs. Not a defect (the program is correct), so it is
99+ # info severity and does not affect the exit code; it surfaces where
100+ # inference could not pin a concrete type (a perf cost, and sometimes the
101+ # first sign of a latent type gap worth a closer look).
102+ rbs = tmp_path("doctor", src, ".rbs")
103+ sh(sp + " " + src + " --emit-rbs -o " + rbs)
104+ widened = []
105+ if File.exist?(rbs)
106+ File.read(rbs).split("\n").each { |l|
107+ widened.push(l.strip) if l.include?("# spinel: widened")
108+ }
109+ end
110+ report("inference", "info", widened, quiet)
111+ end
112+
94113 if leg_on("requires", only, skip)
95114 reqs = []
96115 File.read(src).split("\n").each { |line|