This repository has been archived on 2026-08-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
el-retired/examples/reassign-in-if.el
T
Will Anderson 742bd0b4f9 fix: three foundation/el root-cause bugs (no more bandaids)
1. Parser+codegen: bare reassignment `x = expr` inside an if-body
   was compiling to three orphan expressions with no store. Now
   emits a real assignment.

2. Runtime json_get: dot-path segments that are all digits now
   correctly traverse array indices. `json_get(s, "0.field")` works.

3. Runtime HTTP writer: response bodies starting with
   `{"__status__":<int>,...}` now set the HTTP status header to
   that value and strip the marker from the served body. Existing
   404/401/503 paths in product code now produce real status codes
   instead of HTTP 200 with the status hidden in the body.

Self-host fixed point holds: gen2 == gen3 byte-identical.
Snapshot tagged at dist/platform/elc.20260502-1231-self-host.

Backlog: bl-c121edda
2026-05-02 12:32:23 -05:00

23 lines
653 B
EmacsLisp

// 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
}