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 user type named like a std module's private type breaks that std generic (Mutex.new with a user MutexState): std generic bodies resolve type names against the user's declarations #1745
Spec: §18.2 — name precedence is per module; "a user-controlled declaration is never shadowed, merged, or impl-captured by the fallback tier", and std's own declarations are std's. Found on branch gen-push-pull (#1725); reproduces on main's installed compiler and on the gen-push-impl base.
Repro:
use std.sync.Mutex
type MutexState { x: i32 }
fn main:
let c = MutexState { x: 4 }
let m = Mutex.new(40)
m.set(38)
print(c.x)
Expected: prints 4. Actual:
error: cannot lower projected assignment in 'Mutex.new__receiver__434_4_4' (MIR place 18)
error: code generation failed
Mutex.new[T] (lib/std/sync.w) names its private MutexState; instantiated for the user's call, the name resolves to the user's MutexState. The same happens to any std generic: a user type Box { n: i32 } (test/compile_errors/err_view_dangling.w) made std.task's Pulled[T] { core: Box[PullCore] } fail with "unknown type 'Box' … did you mean 'Box'?", and a user type PullCore breaks g.pull() the same way (so std.task's pull no longer uses Box; the private PullCore name is still exposed to the defect).
Two failures: the wrong resolution itself, and the codegen-phase "cannot lower projected assignment" — Sema accepted a body it had typed against the wrong declaration.
Activity
Codegen: a std-tier declaration a user type shadows keeps its layout …
Type checker: D74 entry sources and chain moves, field-view bindings (w…
g.pull(): a generic instance names its own declaration; a pulled elem…
g.pull(): a generic instance names its own declaration; a pulled elem…
g.pull(): a generic instance names its own declaration; a pulled elem…
g.pull(): a generic instance names its own declaration; a pulled elem…
D70 namespaced types reachable when shadowed (#1757); generator stage…
TypeLayout lays out a generic instance from its own declaration, neve…
TypeLayout lays out a generic instance from its own declaration, neve…
#1647 phases 2–4 completion: owner facts in codegen, per-instance Sem…
fix 750 (#2763)