Skip to content

Open enums3a squashed (open enums without per-enum-case methods) - #654

Open
eliotmoss wants to merge 2 commits into
titzer:masterfrom
eliotmoss:open_enums3a_squashed
Open

Open enums3a squashed (open enums without per-enum-case methods)#654
eliotmoss wants to merge 2 commits into
titzer:masterfrom
eliotmoss:open_enums3a_squashed

Conversation

@eliotmoss

Copy link
Copy Markdown
Contributor

No description provided.

eliotmoss and others added 2 commits April 28, 2026 07:31
…ypes, fields, methods

Squashed snapshot of open_enums3b past master. Adds:

- Open enum types with hierarchical subtypes (`enum E.More { ... }`),
  `case _` defaults, DFS-assigned tag ranges for subtype matching,
  and qualified case access (`E.More.C`).
- Per-case enum method overrides (`Case { def m() ... }`) via
  synthetic per-case VstClass / IrClass / RaClass — Strategy B.
  Cases without overrides share the parent RaClass (elision).
- Subtype enum method overrides (`enum E.More { ...; def m() ... }`)
  with virtual dispatch through the root enum's mtable.
- Subtype field redeclaration / addition (`E.S(super, f: float)`,
  `E.S(super)`, `E.S { D(15) }`) with multi-level inheritance.
- `EnumSetType` for hierarchies (one set type per root, bit positions
  by DFS tag).
- Enum method closures with proper boxing on JVM (Integer) and
  wasm-gc (i31ref); Oop/raw tag receiver convention switched per
  target via NormConfig.
- Queue-based two-dimensional liveness (live cases x live virtuals -> live
  impls) and `-compact-mtable=N` optimization for compacting redundant
  mtable rows via tag->slot indirection.
- JvmV3EnumGen M_ABSTRACT guard, SsaInliner enum NullCheck skip,
  and other backend fixes for v3i / x86 / x86-64 / jar / wasm /
  wasm-gc.
- One master regression fix (lookupEnumExprMember VstField receiver),
  benchmarks (EnumScalability, EnumLiveness, EnumOverrides,
  EnumClosureBoxing), and the wasm bench runner.
- Tutorial and grammar reference updates for open enums.

37/37 ci/Makefile configs pass 3809/3809 tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Squashed delta from open_enums3b to open_enums3a. Strategy A is
Strategy B minus per-case enum method overrides — A and B differ
only in this user-visible feature.

Removed:
  - Parser: parseEnumCaseMembers and the `Case { def m() ... }`
    paths in parseEnumCase. Per-case method bodies are now a parse
    error.
  - Vst: VstCaseMember.members field; synthesizeEnumCaseMember no
    longer creates a synthetic per-case VstClass (decl is null again,
    matching the pre-Strategy-B baseline).
  - Verifier: linkEnumCaseMethods (per-case override IrClass setup)
    and the per-case method body type-check pass; per-case
    synthetic-decl tag setup blocks in assignEnumTagsDFS.
  - Reachability: RaClass.enumCaseRaClasses field and the per-case
    RaClass synthesis path in addEnumCaseClasses. The shared
    queue-based liveness driver is simplified to drop the
    synthetic-RaClass dispatch branch and keep only the
    declaring-enum-level fallback used for subtype dispatch.
  - Eval: lookupEnumVirtual no longer checks synthetic case decls.
  - V3: getSyntheticEnumCaseType (now unused).

Test changes:
  - Deleted test/enums/enum_cmethod00..06.v3 (execution).
  - Deleted test/enums/parser/enum_cmethod00.v3 (was //@parse pass).
  - Added test/enums/parser/no_per_case_method.v3 asserting that
    `Case { def m() ... }` syntax is now a parse error.

Doc changes: removed per-case override sections from
doc/grammar-claude.md, doc/tutorial/EnumMethods.md, and
doc/tutorial/Enums.md (the variant per-case method form in
doc/tutorial/ADTs.md is unchanged).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eliotmoss eliotmoss changed the title Open enums3a squashed (opeb enums without per-enum-case methods) Open enums3a squashed (open enums without per-enum-case methods) Apr 28, 2026
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