From 1f4b9a50683090ac092e8ec50d9eee28b4c55c6b Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Mon, 18 May 2026 16:11:29 +0100 Subject: [PATCH] fix(parse): map Token.EXTERN in the Parse.parse_file token bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- lib/parse.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/parse.ml b/lib/parse.ml index 6c1de196..f327389f 100644 --- a/lib/parse.ml +++ b/lib/parse.ml @@ -85,6 +85,7 @@ let next_token state () = | Token.PUB -> Parser.PUB | Token.AS -> Parser.AS | Token.UNSAFE -> Parser.UNSAFE + | Token.EXTERN -> Parser.EXTERN | Token.ASSUME -> Parser.ASSUME | Token.SELF_KW -> Parser.SELF_KW | Token.TRANSMUTE -> Parser.TRANSMUTE