FAILURE MAP
← Case archive

FA-4046 / Parsing / Open access

A postfix parser reverses noncommutative operands · case 01

A postfix parser reverses noncommutative operands.

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

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Parse a valid postfix token list with binary plus/minus into [operator,left,right] ASTs; letters are leaves.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Parse a valid postfix token list with binary plus/minus into [operator,left,right] ASTs; letters are leaves.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Parse a valid postfix token list with binary plus/minus into [operator,left,right] ASTs; letters are leaves.

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:
        stack=[]
        for t in x:
            if t in ('+','-'):
                left=stack.pop(); right=stack.pop(); stack.append([t,left,right])
            else: stack.append(t)
        return stack[0]
    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(['a', 'b', '-']), ['-', 'a', 'b'])
check('boundary 2', solve(['a', 'b', 'c', '-', '+']), ['+', 'a', ['-', 'b', 'c']])
check('boundary 3', solve(['x']), 'x')
check('boundary 4', solve(['a', 'b', '+']), ['+', 'a', 'b'])
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 1['-', 'b', 'a']['-', 'a', 'b']Failed
boundary 2['+', ['-', 'c', 'b'], 'a']['+', 'a', ['-', 'b', 'c']]Failed
boundary 3xxPassed
boundary 4['+', 'b', 'a']['+', 'a', 'b']Failed

SHA-256 / b67ed1fec0a5126645698da3c9d8027869426200ebe2ae48f59d0c3167bc71db

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:
        stack=[]
        for t in x:
            if t in ('+','-'):
                right=stack.pop(); left=stack.pop(); stack.append(['+',left,right])
            else: stack.append(t)
        return stack[0]
    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(['a', 'b', '-']), ['-', 'a', 'b'])
check('boundary 2', solve(['a', 'b', 'c', '-', '+']), ['+', 'a', ['-', 'b', 'c']])
check('boundary 3', solve(['x']), 'x')
check('boundary 4', solve(['a', 'b', '+']), ['+', 'a', 'b'])
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 1['+', 'a', 'b']['-', 'a', 'b']Failed
boundary 2['+', 'a', ['+', 'b', 'c']]['+', 'a', ['-', 'b', 'c']]Failed
boundary 3xxPassed
boundary 4['+', 'a', 'b']['+', 'a', 'b']Passed

SHA-256 / b2c08386c20855588c5ff2fe4eaddba00e088cb04cb8ecab984cc20d3ff86ff4

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:
        stack=[]
        for t in x:
            if t in ('+','-'):
                right=stack.pop(); left=stack.pop(); stack.append([t,left,right])
            else: stack.append(t)
        return stack[0]
    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(['a', 'b', '-']), ['-', 'a', 'b'])
check('boundary 2', solve(['a', 'b', 'c', '-', '+']), ['+', 'a', ['-', 'b', 'c']])
check('boundary 3', solve(['x']), 'x')
check('boundary 4', solve(['a', 'b', '+']), ['+', 'a', 'b'])
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 1['-', 'a', 'b']['-', 'a', 'b']Passed
boundary 2['+', 'a', ['-', 'b', 'c']]['+', 'a', ['-', 'b', 'c']]Passed
boundary 3xxPassed
boundary 4['+', 'a', 'b']['+', 'a', 'b']Passed

SHA-256 / aab328d79df11d4c37e86304239afa9aecd1d09cc52609f871ab59dc21758fd1

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:34.772608+00:00.

Case digest / d670adcec43fc0b0919fc1ebca46a496d6a2f144861a4b0eed8e6d4373604b61