ludic/docs/language/structure
Orkuncakilkaya 872f458cb2
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 25s
ci / build-and-test (push) Successful in 1m26s
commit-lint / conventional-commits (push) Successful in 2s
docs / build-and-deploy (push) Successful in 23s
feat(types): tagged-union enums — variant payloads + binding match + exhaustiveness (#56)
Extend `enum` from named int constants to a tagged union: a variant may
carry a payload (`enum Tile { Empty, Wall, Door(int), Portal(int, int) }`).
Such enums box to a heap record (an i32 tag at offset 0, then one 8-byte
slot per payload position); an all-bare enum keeps its zero-cost compile-
time-ordinal representation, byte-for-byte unchanged (every golden render
and the bootstrap fixpoint still hold).

- Parser: variant payload declarations, stored as N_PARAM kids on the
  variant node.
- Construction: by name — `Door(3)`, `Portal(x, y)`, bare `Empty` — resolved
  ahead of the function-call fallback and boxed with the payloads coerced to
  their declared types.
- match: destructures a tagged scrutinee, switching on the tag and binding
  each arm's payload names in a scoped local frame.
- Checking pass: a tagged `match` must be exhaustive (cover every variant or
  end in `_`), and constructor/pattern arities and binding forms are checked
  — all reported where the scrutinee's type is known.

Adds selfhost/tests/enums.ludic to the regression suite and documents the
feature in LANGUAGE.md and the enum/match pages.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-01 03:07:46 +03:00
..
_section.md docs: automated documentation pipeline (per-symbol source → pages) 2026-08-29 16:25:54 +03:00
kw-const.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-entry.md feat(stdlib): namespaced standard library (issue #2) 2026-08-30 00:26:19 +03:00
kw-enum.md feat(types): tagged-union enums — variant payloads + binding match + exhaustiveness (#56) 2026-09-01 03:07:46 +03:00
kw-extern.md refactor(lang): rename builtins flr->floor and fx->fixed 2026-08-30 02:01:56 +03:00
kw-function.md refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00
kw-handler.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-import.md feat(lang): new Type { field: value } record initialisers 2026-08-31 01:20:06 +03:00
kw-let.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-model.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-new.md feat(stdlib): namespaced standard library (issue #2) 2026-08-30 00:26:19 +03:00
kw-phase.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-program.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-property.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-public.md feat(stdlib): namespaced standard library (issue #2) 2026-08-30 00:26:19 +03:00
kw-return.md refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00
kw-ui.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
kw-var.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00