Skip to content

Implement nested constructor pattern codegen (#131)#186

Merged
aallan merged 1 commit into
mainfrom
feature/nested-pattern-codegen
Mar 3, 2026
Merged

Implement nested constructor pattern codegen (#131)#186
aallan merged 1 commit into
mainfrom
feature/nested-pattern-codegen

Conversation

@aallan

@aallan aallan commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Nested constructor patterns in match expressions now compile to WASM
  • Previously silently skipped; now first_some in pattern_matching.vera works
  • 5 new tests, 1337 total

Test plan

  • All 1337 tests pass
  • All 15 examples pass
  • mypy clean

Closes #131

Match expressions with nested constructor patterns (e.g.
Cons(Some(@int), _)) now compile to WASM correctly. Previously
any ConstructorPattern or NullaryPattern sub-pattern caused the
function to be silently skipped (return None at L347).

Changes to vera/wasm/data.py:
- _collect_nested_tag_checks: recursively emits tag comparisons
  for nested constructors, AND-chained into the arm condition
- _extract_constructor_fields: recursively loads nested field
  pointers and binds their sub-patterns (ConstructorPattern),
  or advances offset for nullary (NullaryPattern)
- _sub_pattern_wasm_type: resolves WASM types for offset computation
- _translate_match_condition: integrates nested checks after
  outermost tag check

5 new tests, 1,337 total. examples/pattern_matching.vera first_some
now compiles and runs.

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan aallan merged commit 0b46836 into main Mar 3, 2026
18 of 26 checks passed
@aallan aallan deleted the feature/nested-pattern-codegen branch March 3, 2026 19:10
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.

Nested constructor pattern codegen

1 participant