FAILURE MAP
← Case archive

FA-4121 / Sequence semantics / Open access

Last element default · case 01

The operation returns a result or retained state that violates this contract: Return the last element, or None only when the list is empty.

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

ROOT CAUSE

The first positional element is selected instead of the last.

VERIFIED REPAIR

Return the last element, or None only when the list is empty.

Unsuccessful approach: The lexical maximum need not be the final element.

Case contract

Return the last element, or None only when the list is empty. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

Why this case matters

A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return x[0] if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), 'a')
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'c')
check('last is not maximum', solve(['c','a']), 'a')
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
empty collectionNoneNonePassed
singleton collectionaaPassed
two distinct elementsabFailed
nonadjacent duplicate and unsorted orderbcFailed
last is not maximumcaFailed

SHA-256 / a2827f8d1dac9a69b3eb0da540143e21ac0706e95f0dbd4b59d74d863a18f050

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return max(x) if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), 'a')
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'c')
check('last is not maximum', solve(['c','a']), 'a')
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
empty collectionNoneNonePassed
singleton collectionaaPassed
two distinct elementsbbPassed
nonadjacent duplicate and unsorted orderccPassed
last is not maximumcaFailed

SHA-256 / c8ac35b7d3229507354698622752adf6de236e4e449aabce986c4cd139b7d5f4

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return x[-1] if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), None)
check('singleton collection', solve(['a']), 'a')
check('two distinct elements', solve(['a', 'b']), 'b')
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), 'c')
check('last is not maximum', solve(['c','a']), 'a')
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
empty collectionNoneNonePassed
singleton collectionaaPassed
two distinct elementsbbPassed
nonadjacent duplicate and unsorted orderccPassed
last is not maximumaaPassed

SHA-256 / ef7a65e6bd22cd30d6727bb351c9da5fcc3f0cf9c1b17f53ee3a2baf83a8cbff

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

Case digest / 51844c55763358cda4d8dac53d6bdca53752d82a729ab23ece1feb15532bf4b4