You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
migrate: stop emitting pub extern fn for libm names that are now compiler builtins #1153
and the checked-in corpora carry them as pub extern fn (lib/std/re/defs.w:57, lib/std/zl/defs.w:57, lib/std/c_algorithms/defs.w:57, lib/std/tommyds/defs.w:57).
Two things changed under them:
These names are now compiler builtins (src/MathBuiltins.w, D42): cos(x) and x.cos() are width-generic over f32/f64 and lower to the LLVM intrinsic or the width-correct libm symbol. The extern decls are redundant with the builtin.
Per D29 (symbol_visible_from_current, src/Sema.w:2732), every extern fn is globally visible, ungated. So the migrator's extern fn cos(x: f64) is ambient in every program — including a plain user program that imports nothing — because std.re is in the prelude closure (regex literals).
Before the builtin-precedence rule landed, that meant a user's cos(0.0f32) resolved to the corpus extern and returned f64, silently widening the argument:
$ with analyze cos_only.w 'explain:call:cos'
fact mir call ... lib/std/re/defs.w cos sig=106 ... intrinsic=0
check_call now makes a math builtin outrank an extern declaration of its own name (a real, non-extern definition still shadows the builtin), so user code is correct. The remaining cleanup is at the source:
CiMigrate.w should not emit an extern decl for any name in src/MathBuiltins.w. Inside migrated C the call cos(double) resolves to the builtin and lowers to the identical symbol/intrinsic, so behavior is unchanged.
The four corpora then get re-migrated (never hand-edited) so their defs.w drop the decls.
Not blocking: user code is already correct via precedence; this removes the redundant, globally-leaking declarations and the dead branch of resolution.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced. The migrator still writes the libm prelude (src/CiMigrate.w:787-789: extern fn sqrt, extern fn pow, extern fn floor, …), and all six promoted engine corpora carry it in their defs.w. These names are width-generic builtins since D42 (0a0ff13, #1154).
post-release: the output compiles and behaves; per D112 the corpora change only at their next re-promotion.
Fixed in #3257: the migrator's preamble no longer declares extern fn for the 17 names that are math builtins; a migrated call of one is the builtin (the c99_math case asserts the output has no extern fn sqrt/cos). The promoted corpora keep their lines until their next promotion: a migrator change never re-promotes a corpus (D112), so the issue's re-migration step is not done by this change.
Activity
Floating-point math functions are width-generic builtins: cos(x) and …
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced. The migrator still writes the libm prelude (src/CiMigrate.w:787-789:extern fn sqrt,extern fn pow,extern fn floor, …), and all six promoted engine corpora carry it in theirdefs.w. These names are width-generic builtins since D42 (0a0ff13, #1154).post-release: the output compiles and behaves; per D112 the corpora change only at their next re-promotion.
Issues batch G: #2680 #1153 #2369 #2761 #1014 (#3257)
ehartford commentedon Nov 11, 2026
Fixed in #3257: the migrator's preamble no longer declares
extern fnfor the 17 names that are math builtins; a migrated call of one is the builtin (the c99_math case asserts the output has noextern fn sqrt/cos). The promoted corpora keep their lines until their next promotion: a migrator change never re-promotes a corpus (D112), so the issue's re-migration step is not done by this change.