Skip to content

fix(parse): map Token.EXTERN in Parse.parse_file token bridge (runtime Match_failure on all extern code)#219

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/parse-extern-token
May 18, 2026
Merged

fix(parse): map Token.EXTERN in Parse.parse_file token bridge (runtime Match_failure on all extern code)#219
hyperpolymath merged 1 commit into
mainfrom
fix/parse-extern-token

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

parse.ml next_token's Token→Parser match omitted EXTERN. Warning-8 demotion in lib/dune let the non-exhaustive match compile, then it raised Match_failure at runtime on any extern token — breaking Parse.parse_file for all FFI-heavy stdlib (Deno/Vscode/Network/Sqlite/Crypto/…). One-arm wiring; Parser.EXTERN already existed.

Verified: previously-crashing stdlib/Deno|Vscode|Network now parse OK; dune test --force 257/257 green.

Surfaced by the #218 record-migration codemod (relies on Parse.parse_file).

Refs #218

🤖 Generated with Claude Code

parse.ml's Token->Parser match (next_token) was missing the EXTERN
case. lib/dune demotes partial-match (warning 8) from error, so the
non-exhaustive match compiled but raised Match_failure at RUNTIME the
moment any `extern` token reached Parse.parse_file — i.e. on every
FFI-heavy file (all of stdlib/Deno, Vscode, Network, Sqlite, Crypto,
... use `extern fn`/`extern type`). Parser.EXTERN already existed;
this just wires the one missing arm.

Effect: Parse.parse_file (the public string/file parse API) now
handles extern-bearing sources instead of crashing. Verified the
previously-crashing stdlib/Deno|Vscode|Network now parse OK; full
dune gate green (257/257), zero regression.

Surfaced by the affinescript#218 record-migration codemod, which
relies on Parse.parse_file and was blocked on stdlib by this.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit 18911aa into main May 18, 2026
@hyperpolymath hyperpolymath deleted the fix/parse-extern-token branch May 18, 2026 15:11
hyperpolymath added a commit that referenced this pull request May 18, 2026
…; resolves #215 C+D) (#222)

* wip(#218): Rust-like record syntax — grammar + token bridges + 6 fixtures

ATOMIC PR IN PROGRESS — DO NOT MERGE (15/257 still failing).

Contains:
- Grammar: bare { = block, records #{ } (token.ml/lexer.ml/parser.mly,
  from stage-c/pc-brace-disambig). Conflicts 72->68 S/R, 10->7 R/R.
- Token-bridge completeness: added HASH_LBRACE arm to BOTH
  lib/parse.ml AND lib/parse_driver.ml (same non-exhaustive-match
  class as #219 EXTERN — warning-8 demoted, Match_failure at runtime;
  these were the ONLY two Token->Parser bridges).
- Migrated 6 regression .affine fixtures (expression-position record
  literals {..}->#{..}; type-position records unchanged).

Progress: 21 -> 15 failures. Remaining 15 are inline AffineScript
source embedded as string literals in the OCaml test suite (E2E TEA
counter/titlescreen, LSP Phase B hover, full_pipeline, AOT test 17,
etc.) — those test inputs still use old record syntax and need #{
migration in the test .ml fixtures, not .affine files.

Refs #218

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(#218)!: complete Rust-like record migration — 257/257 green

Migrated the remaining expression-position record literals to #{ }
(compiler-as-oracle, iterated to green):
- test/e2e/fixtures/counter.affine (tea_run arg record)
- test/e2e/fixtures/full_pipeline.affine (fn-return + Rect(#{}) arg)
- test/e2e/fixtures/titlescreen.affine (title_init body + 4 match-arm
  records + tea_run arg)
- examples/comprehensive_test.affine (fn-return + Rect(#{}) arg)
- stdlib/testing.affine (benchmark-result record — the ONE stdlib
  record literal; earlier survey missed it, parse-gated)

Type-position records, struct/type declarations, blocks, and match-arm
blocks left unchanged (different grammar rules — verified).

Full dune gate now GREEN: 257/257, 0 failures. Conflicts 72->68 S/R,
10->7 R/R (residual families tracked on #215). Breaking syntax change
— review-gated, do not auto-merge.

Refs #218 #215

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 44 issues detected

Severity Count
🔴 Critical 12
🟠 High 21
🟡 Medium 11

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Stray AI.a2ml in root -- use 0-AI-MANIFEST.a2ml only",
    "type": "banned",
    "file": "AI.a2ml",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Superseded by 0-AI-MANIFEST.a2ml",
    "type": "banned",
    "file": "AI.djot",
    "action": "delete",
    "rule_module": "root_hygiene",
    "severity": "high"
  },
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/compile.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/runner.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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