FAILURE MAP
← Case archive

FA-4386 / Mapping semantics / Open access

Map setdefault keeps existing none · case 01

The operation returns a result or retained state that violates this contract: Insert the default only for an absent key; return [selected value,map].

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

ROOT CAUSE

Unconditional assignment overwrites an existing binding.

VERIFIED REPAIR

Insert the default only for an absent key; return [selected value,map].

Unsuccessful approach: A None-based presence check replaces legitimate None values.

Case contract

Insert the default only for an absent key; return [selected value,map]. 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):
    a=dict(x); a[y[0]]=y[1]; return [y[1],a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('existing None', solve({'a': None}, ['a', 'd']), [None, {'a': None}])
check('existing scalar', solve({'a': 'v'}, ['a', 'd']), ['v', {'a': 'v'}])
check('absent key', solve({}, ['a', 'd']), ['d', {'a': 'd'}])
check('existing false', solve({'a': False}, ['a', 'd']), [False, {'a': False}])
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
existing None['d', {'a': 'd'}][None, {'a': None}]Failed
existing scalar['d', {'a': 'd'}]['v', {'a': 'v'}]Failed
absent key['d', {'a': 'd'}]['d', {'a': 'd'}]Passed
existing false['d', {'a': 'd'}][False, {'a': False}]Failed

SHA-256 / e10676ede3e310abeec06619303770af942afecba87480df2834fb3b75398fd2

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x, y=None):
    a=dict(x)
    if a.get(y[0]) is None: a[y[0]]=y[1]
    return [a[y[0]],a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('existing None', solve({'a': None}, ['a', 'd']), [None, {'a': None}])
check('existing scalar', solve({'a': 'v'}, ['a', 'd']), ['v', {'a': 'v'}])
check('absent key', solve({}, ['a', 'd']), ['d', {'a': 'd'}])
check('existing false', solve({'a': False}, ['a', 'd']), [False, {'a': False}])
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
existing None['d', {'a': 'd'}][None, {'a': None}]Failed
existing scalar['v', {'a': 'v'}]['v', {'a': 'v'}]Passed
absent key['d', {'a': 'd'}]['d', {'a': 'd'}]Passed
existing false[False, {'a': False}][False, {'a': False}]Passed

SHA-256 / 660652cef6fa1fda125deb7734b038b89d7ae24b39ccddf31564bd7e6fb9e64b

3 / The verified repair

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

N = 1
observations = []
def solve(x, y=None):
    a=dict(x); v=a.setdefault(y[0],y[1]); return [v,a]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('existing None', solve({'a': None}, ['a', 'd']), [None, {'a': None}])
check('existing scalar', solve({'a': 'v'}, ['a', 'd']), ['v', {'a': 'v'}])
check('absent key', solve({}, ['a', 'd']), ['d', {'a': 'd'}])
check('existing false', solve({'a': False}, ['a', 'd']), [False, {'a': False}])
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
existing None[None, {'a': None}][None, {'a': None}]Passed
existing scalar['v', {'a': 'v'}]['v', {'a': 'v'}]Passed
absent key['d', {'a': 'd'}]['d', {'a': 'd'}]Passed
existing false[False, {'a': False}][False, {'a': False}]Passed

SHA-256 / 1658e46243ccc213b75c5d128c16d05297599c56a6b2e7a03d641af610363778

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

Case digest / 895318ca13130d41339130014d2bda1bc342b3f1d0db315be7dcf2c163760aa1