Skip to content

Enum member names are not lexical bindings#178

Merged
kollhof merged 1 commit into
mainfrom
enum-members-not-bound
Jun 14, 2026
Merged

Enum member names are not lexical bindings#178
kollhof merged 1 commit into
mainfrom
enum-members-not-bound

Conversation

@kollhof

@kollhof kollhof commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary

Fixes a scope-resolution mistake from #177: enum member names (Some / None) were being registered as lexical bindings. They should not be.

Per the type-system design, enum members do not leak into the enclosing lexical scope — they are reached via Enum.Some (qualified) or {Some} = Enum (destructure), which is a type-system concern, not lexical scoping. The lexical-scopes pass now treats a constructor name like a record field name: neither bound nor resolved; only the payload types resolve against the generic params.

Change

walk_type_member:

  • Some T (payload constructor) — skip the constructor name, resolve only the payload args as type references.
  • None (nullary constructor) — neither bound nor resolved.

Testing

Full suite green: 1345 lib + 42 CLI + 1 interop, 0 failed. Updated the test_scope_types.fnk enum fixture to assert no bind for Some/None (only bind 'T' for the generic param and ref 'T' for the payload).

Enum members (Some/None) do not leak into the lexical scope -- they are
reached via Enum.Some / destructure, a type-system concern. The
lexical-scopes pass now treats a constructor name like a record field
name: neither bound nor resolved; only the payload types resolve. Fixes
the earlier walk_type_member registering Some/None as binds.
@github-actions

Copy link
Copy Markdown

📦 This PR will release v0.86.1 (patch) when merged.

@kollhof kollhof merged commit 6128b9a into main Jun 14, 2026
14 checks passed
@kollhof kollhof deleted the enum-members-not-bound branch June 14, 2026 19:01
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