Archived
restructure: move el compiler content into lang/
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// reassign-in-if.el — acceptance test for bare reassignment inside if-body.
|
||||
//
|
||||
// Before fix: parser dropped `x = "override"` on the floor and codegen emitted
|
||||
// three orphan expressions (`x; EL_NULL; EL_STR("override");`). Effective store
|
||||
// was lost, so the function returned "default".
|
||||
//
|
||||
// After fix: parse_stmt recognises `Ident "=" Expr` as an Assign statement and
|
||||
// codegen emits a real C assignment, so the function returns "override".
|
||||
|
||||
fn test_reassign() -> String {
|
||||
let x: String = "default"
|
||||
if true {
|
||||
x = "override"
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
fn main() -> Int {
|
||||
let r: String = test_reassign()
|
||||
print(r)
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user