Skip to content

fix inline struct field access and revert TryStatement flattening#10

Merged
cs01 merged 5 commits intomainfrom
compiler-improvements
Feb 19, 2026
Merged

fix inline struct field access and revert TryStatement flattening#10
cs01 merged 5 commits intomainfrom
compiler-improvements

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Feb 19, 2026

Summary

  • Fix a root cause bug in storeInterfaceMetadata where accessing fields on anonymous nested struct types (like stmt.catchClause.body) silently produced wrong values. Added a third branch that parses inline { field: type; ... } type strings and stores proper metadata for chained member access.
  • Revert the TryStatement flattening workaround (catchParam/catchBody → nested catchClause: { param, body }) now that the root cause is fixed. This restores the natural TypeScript representation.
  • Add code style guidelines to .claude/rules.md (prefer named AST types, comment style for codegen blocks).

Changed files

  • src/codegen/expressions/access/member.ts — new inline struct branch in storeInterfaceMetadata
  • src/ast/types.tsTryStatement uses nested catchClause again
  • src/parser-ts/handlers/statements.ts — produce catchClause: { param, body }
  • src/parser-native/transformer.ts — produce catchClause: { param, body }
  • src/analysis/semantic-analyzer.ts — read catchClause.param / catchClause.body
  • src/ast/visitor.ts — walk catchClause.body
  • src/codegen/infrastructure/closure-analyzer.ts — walk catchClause.body
  • src/codegen/statements/control-flow.ts — read catchClause.param / catchClause.body
  • .claude/rules.md — code style section

Test plan

  • All 279 tests pass (only pre-existing network test failures from missing lws-bridge.o)
  • All 4 try/catch test fixtures pass with the nested catchClause struct
  • Self-hosting Stage 0 + Stage 1 pass
  • Stage 1 proves the fix works end-to-end: the native compiler correctly compiles code that accesses catchClause.body through the inline struct metadata path

@cs01 cs01 merged commit 5271d53 into main Feb 19, 2026
11 checks passed
@cs01 cs01 deleted the compiler-improvements branch February 19, 2026 06:33
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