Skip to content

stale docs cleanup, semantic analyzer warning, and variable allocator refactoring#11

Open
cs01 wants to merge 1 commit intomainfrom
shard-d-variable-allocator-docs-cleanup
Open

stale docs cleanup, semantic analyzer warning, and variable allocator refactoring#11
cs01 wants to merge 1 commit intomainfrom
shard-d-variable-allocator-docs-cleanup

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Feb 19, 2026

Summary

Shard D of the compiler rearchitecture plan: stale docs cleanup, semantic analyzer warning, and variable allocator refactoring.

  • D1: Update stale docs — Removed the outdated "optional chaining compiles to direct access" warning from rules.md (generateOptionalChain already emits proper icmp/phi null checks). Updated the new in class field initializers note to reflect that codegen now handles it. Added regression test fixture for optional chaining on interfaces and strings.
  • D2: Class field initializer warning — Added a compile-time warning in the semantic analyzer when new X() appears in a class field initializer, guiding developers to prefer constructor initialization.
  • D3: Extract VarKind classification — Added a VarKind enum (27 variants) and classifyVariable() method to variable-allocator.ts, making the priority-ordered type classification logic explicit and independently testable.
  • D4: Switch dispatch — Replaced the 54-line if/else chain in allocate() with a switch on VarKind, dispatching to the same existing allocateX() methods.

Files changed

  • .claude/rules.md — removed stale warnings, updated class field initializer docs
  • src/analysis/semantic-analyzer.ts — added new X() field initializer warning
  • src/codegen/infrastructure/variable-allocator.ts — added VarKind enum, VarClassification interface, classifyVariable() method, switch dispatch
  • tests/test-fixtures.ts — registered 2 new test fixtures
  • tests/fixtures/types/optional-chaining.ts — new regression test
  • tests/fixtures/classes/class-field-new.ts — new regression test

Test plan

  • npm test — all tests pass (only pre-existing try-catch failures)
  • bash scripts/self-hosting.sh — full 3-stage self-hosting passes
  • New test fixtures compile and run correctly
  • No new test failures introduced

@cs01 cs01 changed the title shard D: update stale docs, add class field warning, extract VarKind … stale docs cleanup, semantic analyzer warning, and variable allocator refactoring Feb 19, 2026
@cs01 cs01 force-pushed the shard-d-variable-allocator-docs-cleanup branch from 61b6195 to 1e0aeea Compare February 19, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments