Commit 203c72c7

203c72c77fc2Merged

Ryan Seys <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

feat(parse): support MissingNode (parse-error placeholder; defensive handler)

Adds a parser case for PM_MISSING_NODE that exits with a clear internal-error message. Prism emits MissingNode as an error-recovery placeholder; the parser's main loop bails on parse errors before flatten() is called (spinel_parse.c:1201), so reaching this case indicates Prism produced a MissingNode without flagging an error in error_list -- a contract violation we surface clearly rather than route through the generic UnsupportedNode path.

No test fixture: this path is unreachable from valid or invalid Ruby in normal use (the error_list bail catches both). The handler is defense-in-depth in case Prism's contract changes.

Tests: 252 still pass. Bootstrap: gen2.c == gen3.c.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
203c72c77fc2
Parent
6322a5e35310

spinel_parse.cmodifiedView file

@@ -794,6 +794,16 @@
794794 node_counter--;
795795 return flatten(n->value);
796796 }
797+ case PM_MISSING_NODE: {
798+ /* Prism emits MissingNode as an error-recovery placeholder. main()
799+ bails out before flatten() runs when parser.error_list is
800+ non-empty, so reaching this case means Prism produced a
801+ MissingNode without flagging an error -- a contract violation we
802+ surface clearly rather than silently miscompile. */
803+ fprintf(stderr, "spinel_parse: internal error: MissingNode reached flatten() at byte offset %td; parse error not in error_list\n",
804+ node->location.start - g_parser->start);
805+ exit(1);
806+ }
797807 case PM_SPLAT_NODE: {
798808 pm_splat_node_t *n = (pm_splat_node_t *)node;
799809 N("SplatNode");