◀ THE FOLD0ROOT.AI // WORLD II · GLITCH · UNDEFINED BEHAVIOR◆ .dlw.fold
THE FOLD / GLITCH / UNDEFINED BEHAVIOR / THE NAME OUTSIDE THE PARENS

THE NAME OUTSIDE THE PARENS

the wrong answer of the right type
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
A regular expression cannot count. Hand it something that nests and it does not refuse — it matches the part it can reach and returns that, with no indication that the rest of the structure was ever there.

LIT verified live. over all 196 balanced-parenthesis strings of up to six pairs — the Catalan numbers 1, 2, 5, 14, 42, 132 — a one-level nesting pattern spans the whole string in 6 cases, returns a partial match in 190, and fails to match in 0. It is wrong 96.9% of the time and silent 100% of the time. On the case that matters, dasum:dx((+ i 1)), it returns (+ i 1) — the index survives and the array name is gone, because the name is the one component that sits outside every bracket.
2 HOW IT WAS WEAVED · AI + HUMAN
That regular languages cannot recognise balanced parentheses is the pumping lemma, and is older than every tool this happens in.

AVAN (AI) counted the failure modes rather than restating the theorem, because the theorem says the pattern is wrong and the count says it is quiet. The 0 is the whole finding: not one of 196 inputs produced a non-match. A pattern that failed loudly would be a nuisance; this one hands back a well-formed answer of the right type, and the loss shows up four call frames away as an unbalanced token stream naming neither parentheses nor names.
3 ONE DIMENSION
196 balanced strings. 190 wrong. 0 complaints.
4 TWO DIMENSIONS · INTERACTIVE
Grow the nesting and watch the match stop keeping up.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object.
AVAN’s addition (the inverse-companion): the forward reading is: do not parse nesting with a regex. The inverse is that the danger is not the wrongness, it is the type. The pattern returns a string when a string was expected; nothing downstream can tell a truncated capture from a complete one, because both are strings and both are non-empty. Read backwards, the reason this bug is written again and again is that the failure is type-correct — and every safeguard we have, from static types to assertions to the shape of a return value, is watching the type.
LIT over all 196 balanced-parenthesis strings of up to six pairs - the Catalan numbers 1, 2, 5, 14, 42, 132 - a one-level nesting pattern spans the whole string in 6 cases, returns a partial match in 190, and fails to match in 0, so it is wrong 96.9% of the time and silent 100% of the time; on the case that mattered, dasum:dx((+ i 1)), it returns (+ i 1) - the index survives and the array NAME is gone, because the name is the one component that sits outside every bracket

FIG That regular languages cannot recognise balanced parentheses is the pumping lemma. AVAN counted the failure modes rather than restating the theorem, because the theorem says the pattern is wrong and the count says it is QUIET: not one of 196 inputs produced a non-match. A pattern that failed loudly would be a nuisance; this one hands back a well-formed answer of the right type, and the loss surfaces four call frames away as an unbalanced token stream naming neither parentheses nor names.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of UNDEFINED BEHAVIOR · David Lee Wise (ROOT0), with AVAN