Skip to content

Match pattern payload slot: five readers, three disagreeing heuristics, one live misparse (Resolve.w kind-range) #663

Closed

Description

@ehartford

The NK_PAT_VARIANT / NK_PAT_ENUM_SHORTHAND payload extras are the surviving sibling of #660's untagged union (binder SYMBOL id vs nested pattern NODE id). A census found FIVE readers with THREE different discriminators:

  • MirLower.w:7063 pattern_payload_node — is_pattern_node + span containment probe (a misfire silently drops payload match checks or binds payloads to garbage symbols; the Pool/ID-integrity: adding one declaration corrupts parsing or name resolution of later-parsed modules (issue61-regression canary, red since <=10f7771e) #660 analog inside match lowering).
  • Resolve.w:899-911 bind_pattern — a DIVERGENT numeric kind-range probe (100..113) that wrongly INCLUDES NK_MATCH_ARM (=110, not a pattern) and EXCLUDES NK_PAT_TYPED_BIND (114), NK_PAT_REGEX (121), NK_PAT_REST (125). Live today with no id collision needed: 'Variant(x, ..)' or 'Variant(x: T)' routes the payload to the else branch and add_def registers a DK_LOCAL whose name symbol is actually a pattern NODE id — a garbage binding in the resolver's tables.
  • render.w:939/957 — bare is_pattern_node, no span check (wrong rendered/diagnostic text on collision).
  • SemaCheck.w:11769 and ComptimeEval.w:6107 — no probe at all; unconditionally treat the entry as a node.

Every CURRENT producer (Parser.w pattern paths, ComptimeTransform.w:2472) stores NODES, so the sym-guessing branches are dead-but-load-bearing. Fix direction: declare the slot node-only and delete the sym branches in all three probing readers (or tag-map it like #660's fix in Ast.w pattern_binding_keys). Found during the post-#660 pattern census.

Activity

  1. ehartford commented on Jul 14, 2026

    @ehartford
    ContributorAuthor

    Fixed in a441999. Two parts: (1) the resolver's variant-payload slot used a numeric kind-range probe (100..113) that excluded NK_PAT_TYPED_BIND/REGEX/REST and included the non-pattern NK_MATCH_ARM — so V(x: T) registered a garbage node-id-as-symbol binding; replaced with is_pattern_node, deleted the dead sym branch, added the missing NK_PAT_TYPED_BIND binder. (2) fixing the resolver exposed that a typed-bind pattern is a dyn-trait downcast whose MIR handler segfaults on a concrete (non-trait-object) subject; Sema now rejects it loudly. The dyn-downcast use (sealed_trait_match) is unaffected. Full gate green. Note: this was the live-misparse reader; the render.w/SemaCheck/Comptime readers listed in the issue are dead-but-harmless (all producers store nodes) and can be swept under #651 if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions