FAILURE MAP
← Case archive

FA-3426 / Lexical grammars / Open access

A reserved word passes lexical identifier validation · case 01

A reserved word passes lexical identifier validation.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The recognizer uses '[a-z_][a-z0-9_]*', which admits or omits a token shape forbidden by the stated grammar.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Accept lowercase ASCII identifiers except if, for and while.

Unsuccessful approach: The candidate grammar '(?!if|for|while)[a-z_][a-z0-9_]*' still disagrees with the explicit boundary fixtures.

Case contract

Accept lowercase ASCII identifiers except if, for and while.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(re.fullmatch('[a-z_][a-z0-9_]*',x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('if'), False)
check('boundary 2', solve('format'), True)
check('boundary 3', solve('while2'), True)
check('boundary 4', solve('a_b'), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1TrueFalseFailed
boundary 2TrueTruePassed
boundary 3TrueTruePassed
boundary 4TrueTruePassed

SHA-256 / d6e6fec7f5183a04363065f17d0136d74faf9f9d8512062578ad2e40eaf75782

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(re.fullmatch('(?!if|for|while)[a-z_][a-z0-9_]*',x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('if'), False)
check('boundary 2', solve('format'), True)
check('boundary 3', solve('while2'), True)
check('boundary 4', solve('a_b'), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1FalseFalsePassed
boundary 2FalseTrueFailed
boundary 3FalseTrueFailed
boundary 4TrueTruePassed

SHA-256 / eaf3bacb7b3f268ff12631984415f3beaaca1ce63c7e84b1ba67b36fc4d61212

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(re.fullmatch('(?!(?:if|for|while)\\Z)[a-z_][a-z0-9_]*',x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('if'), False)
check('boundary 2', solve('format'), True)
check('boundary 3', solve('while2'), True)
check('boundary 4', solve('a_b'), True)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1FalseFalsePassed
boundary 2TrueTruePassed
boundary 3TrueTruePassed
boundary 4TrueTruePassed

SHA-256 / a510e2db82195f4331b712c1a9be9a66cfe7dcab3286522b727e7735f208ba22

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:25.659476+00:00.

Case digest / a317193cf1d1858c427c299ba2337dbe9bd7c3559690d6df8dd855436b53157c