ludic/selfhost
Orkuncakilkaya e1d7797e29 Phase 6f: let = immutable, var = mutable (binding-only)
Bindings now signal mutability the way Rust/Swift do, instead of `let` meaning
"local" and `var` meaning "module-level":

  - `let x = e`  -> immutable binding; a later `x = …` is a compile error
    (`cannot assign to immutable 'x' … use var`).
  - `var x = e`  -> mutable binding, at local OR module scope (position decides
    scope; the keyword decides mutability).
  - `const`      -> unchanged (compile-time).

Immutability is of the *binding*, not the object: `let n = new Node; n.kind = 1`
is fine (mutation through the reference); only rebinding `n` is rejected. The
check lives in emit_assign — a direct `name =` whose target is a `let` local
(loc_mut == 0) errors; field/index targets and `var`/param/loop bindings are
unaffected.

Delivered as three reseeds so the self-hosting compiler never had to compile
source its own rules would reject:
  A) add `var` as a local statement + per-local mutability tracking (loc_mut),
     no enforcement;
  B) migrate every reassigned `let` -> `var` across the compiler, runtime and
     examples (337 declarations), driven by a per-function, string/comment-aware
     scan (binding targets only, never `x.f =` / `x[i] =`);
  C) turn on the check. bootstrap-cfree (compiler vs its own source) and every
     golden build (which splices the runtime) then proved zero reassigned `let`
     was missed anywhere.

Also folded in: removed leftover debug instrumentation in block() (a `cur=` /
print_int(777…) trace on the separator-error path) and fixed parse.ludic's stale
header comment (no more `struct`). Reseeded (21711 lines); C-free fixpoint holds;
goldens identical; 17/17; vocab + doc-fences clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-27 23:52:59 +03:00
..
golden Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
tests Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
ast.ludic Phase 6d: merge struct into property; storage follows use 2026-08-27 23:32:05 +03:00
bootstrap-cfree.sh Phase 6a: rename core vocabulary (game/main/component/archetype/system) 2026-08-27 18:22:13 +03:00
bootstrap.sh Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
buf.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
build.sh Phase 6a: rename core vocabulary (game/main/component/archetype/system) 2026-08-27 18:22:13 +03:00
compile.sh Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
emit_addr.ludic Phase 2: enforce statement separators (Rule B) 2026-08-27 15:41:29 +03:00
emit_core.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_decl.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_ecs.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_expr.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_game.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_head.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_intrin.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_intrin2.ludic Phase 2: enforce statement separators (Rule B) 2026-08-27 15:41:29 +03:00
emit_machine.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_math.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_new.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_query.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_save.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_spawn.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_stmt.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
emit_ui.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
game-build.sh Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00
io.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
lex.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
ludicc.seed.ll Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
main.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
parse.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
parse_game.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
reseed.sh Phase 6a: rename core vocabulary (game/main/component/archetype/system) 2026-08-27 18:22:13 +03:00
str.ludic Phase 6f: let = immutable, var = mutable (binding-only) 2026-08-27 23:52:59 +03:00
test.sh Baseline: Ludic compiler + toolchain, Phase 1 syntax fixes complete 2026-08-27 15:15:35 +03:00