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
CCodegen.global_decl_tid: an extern var whose type does not resolve is silently emitted as i32 #1429
Found while fixing the emit-C reds of #1377 (#1362). Code reading, not yet a repro.
src/CCodegen.w, global_decl_tid: when an extern var's declared type does not resolve through sema.resolve_type_expr_frozen, the global is emitted as i32:
if dk == NodeKind.NK_EXTERN_VAR:
let type_node = self.ast.get_data1(decl)
let tid = ...resolve...(type_node)
if tid != 0:
return tid
return self.sema.ty_i32 as i32
That is a silent fallback (AGENTS.md "No Silent Fallbacks"): an extern var whose type the C backend cannot resolve is declared int in the emitted C instead of failing loudly. Until #1377, frozen resolution in CCodegen ran from whatever module sema.current_module_path held. The root module could not see a type, so the i32 branch was reachable for any global whose type the root cannot name. #1377 resolves a declaration's type in its declaring module, which removes that route. The fallback itself is still there.
Expected: self.fail(...) naming the global and its type spelling, like the sizeof path does since #1377.
Activity
CCodegen: frozen type resolution runs in the declaring module; a fail…
CCodegen: frozen type resolution runs in the declaring module; a fail…
Sema/Frontend: engine corpora never ambient (§18.2); bundle interface…
CCodegen: a global whose type cannot be recovered fails loudly instea…
CCodegen: a global whose type cannot be recovered fails loudly instea…