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
A default argument resolves in the caller scope: a program that declares its own src() captures panic(loc: &str = src()) and the checker reports a bogus argument error inside embedded std #2568
use std.builtins.print_bool
extern fn src() -> i32
fn main: print_bool(true)
error: wrong argument type in call to 'panic'
--> <embedded-std>/std/string.w:103:32
= label @103:32 argument expression 'src()' has type i32 (the user's src)
= note: parameter 'loc' expects &str
A plain fn src() -> *mut i32: null instead gives symbol 'src' is not visible from this module at std/builtins.w:97 (the default argument of panic). Renaming the function (srcx) passes.
Cause (hypothesis, from the sites)
lib/std/builtins.w:97: pub fn panic(msg: &str, loc: &str = src()) -> Never. The default argument's expression is re-resolved at each call site in the caller's scope, so a caller module that declares src shadows the builtin (Sema.syms.src). The reported location (string.w:103, a doc-comment line) is the default-argument node's span, not the call's.
Expected
A default argument is evaluated in the callee's declaring scope (hygiene), or src() is an intrinsic no user name can shadow. Found by a C migrator fixture whose C function was named src (M*LIB Phase 4 work).
Activity
Phase 4: BTreeMap and BTreeSet over the M*LIB B+tree (D151); D152; D1…