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
D32: an if/else arm naming a mut-receiver field moves it out silently (field blanked, no diagnostic) #1395
§2.2 / D32 (STRICT): a field never moves out implicitly; the only vacate is an explicit move place.field. An if-expression arm evades the check and vacates the field:
type S { p: str }
impl S:
mut fn f():
let path = if self.p.len() > 0: self.p else: ""
print(path)
fn main:
var s = S { p: "abc" }
s.f()
print(f"after=[{s.p}]")
Installed compiler and stage2 from main: with check ok; run prints abc then after=[]. The plain let path = self.p in the same receiver does not vacate (prints after=[abc]). Expected: the D32 move-site error with its move / .clone() fix-its (or, if a view binding is the ruling for the arm too, no vacate) — never a silent blank.
Found in #1364 (#1350): Sema.record_displaced_fn used this shape on self.current_module_path; collect_fn_decl then resolved the displaced fn's parameter types with an empty module path, so the --no-std tier gate treated std's own fence(order: Order) as user code (error: Order requires std --> <embedded-std>/std/collections.w:330), located with a [dbg] print of current_module_path at Sema.w require_std_tier_for_symbol ("" ) after collect_declarations set it to collections.w. The same shape already sat in Sema.record_named_type_with_pub (a mut fn, blanking current_module_path mid type collection) and the embed_file check in SemaCheck.w; #1364 rewrites all three to with_str_clone_ref(self.current_module_path) as the workaround this issue removes the need for.
The match-arm form (match c: true => self.p ...) should be checked in the same fix.
Activity
Sema: never move current_module_path out of the receiver; re-record t…
Frontend/Sema: a fn another module shadows keeps its module-qualified…
Spell the field moves the #1395 check finds: .clone() to keep the own…
Sema: a field that reaches an owned join, block tail or break value i…
Spell the field moves the #1395 check finds: .clone() to keep the own…
Sema: a field that reaches an owned join, block tail or break value i…
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership: a move out of a place projected through a referen…
validate-ownership rejects vacated payloads and moves through referen…
Sema/MIR: a join whose arms are all non-Copy field places is a view o…
Sema/MIR: a join whose arms are all non-Copy field places is a view o…
Restore Vec.clone in drop-state storage; pin the cross-unit receiver …