Commit f10557d9

f10557d9d8c0Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Merge pull request #1476 from OriPekelman/doctor-inference-leg

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

Details

Commit
f10557d9d8c0
Parent
5914c9e1bef6
Merge parent
8e5a1a4af890

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|