feat: match guards, HOF inference, ownership C.2/C.3, LSP sema hover
Sessions 18–23 quality work: - B.3c match arm guards + sequential found-flag lower (bootstrap + selfhost) - Generic HOF type inference (Array/Iter map/filter/fold without type args) - Pattern binding shadowing via unique C locals (__pN_src) - Ownership C.2 exclusive &mut data-flow + C.4 goldens; *p= store-through fix - Ownership C.3 auto-drop on early return/branches: scoped defers, move-on-return, Drop monomorphization, materialize return before Drop - LSP 0.3.0: hover from real sema types - Examples and QUALITY_PLAN session log; selfhost-loop identical
This commit is contained in:
@@ -195,6 +195,46 @@ func Main() -> int {
|
||||
""")
|
||||
check(not res.hasErrors)
|
||||
|
||||
test "@[Checked] rejects two let-bound &mut of same var":
|
||||
let res = checkSource("""
|
||||
@[Checked]
|
||||
func Main() -> int {
|
||||
var x: int = 1;
|
||||
let a: &mut int = &x;
|
||||
let b: &mut int = &x;
|
||||
return 0;
|
||||
}
|
||||
""")
|
||||
check(res.hasErrors)
|
||||
check(res.diagnostics[0].message.contains("already mutably borrowed"))
|
||||
|
||||
test "@[Checked] rejects assign while mutably borrowed":
|
||||
let res = checkSource("""
|
||||
@[Checked]
|
||||
func Main() -> int {
|
||||
var x: int = 1;
|
||||
let a: &mut int = &x;
|
||||
x = 2;
|
||||
return *a;
|
||||
}
|
||||
""")
|
||||
check(res.hasErrors)
|
||||
check(res.diagnostics[0].message.contains("mutably borrowed"))
|
||||
|
||||
test "@[Checked] rejects shared borrow while mutably borrowed":
|
||||
let res = checkSource("""
|
||||
@[Checked]
|
||||
func Main() -> int {
|
||||
var x: int = 1;
|
||||
let a: &mut int = &x;
|
||||
let b: &int = &x;
|
||||
return 0;
|
||||
}
|
||||
""")
|
||||
check(res.hasErrors)
|
||||
check(res.diagnostics[0].message.contains("shared-borrow") or
|
||||
res.diagnostics[0].message.contains("mutably borrowed"))
|
||||
|
||||
test "borrow & expr with shared ref":
|
||||
let res = checkSource("""
|
||||
struct Point {
|
||||
|
||||
Reference in New Issue
Block a user