FAILURE MAP
← Case archive

FA-44126 / Borrow checking / Open access

Enum construction attaches a payload borrow to the wrong variant · case 01

Enum construction attaches a payload borrow to the wrong variant.

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

ROOT CAUSE

The static analyzer mishandles enum loan discriminant: enum construction attaches a payload borrow to the wrong variant.

THE FAILURE

The static analyzer mishandles enum loan discriminant: enum construction attaches a payload borrow to the wrong variant.

Unsuccessful approach: The partial repair uses if d['payload_loan'] and d['actual_variant'] is None: errors.append('enum-loan-discriminant'), which still violates the stipulated analysis contract.

Case contract

Validate lowering of aggregate expressions containing owned and borrowed fields. Evaluation order follows source field order; struct update moves only omitted fields; explicit fields override update sources; failed construction drops initialized fields in reverse initialization order; borrowed fields preserve their source origin; spread cannot duplicate exclusive fields; tuple projection indices remain positional; enum payload loans require matching discriminant; moving an aggregate remaps every contained reference owner slot; zero-field aggregates create no synthetic borrowed field. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

Why this case matters

A finite offline static-analysis model of ownership and borrowing; it does not execute the analyzed program.

1 / The failure

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

N = 1
observations = []
def solve(d):
    errors=[]
    if d['source_order']!=d['eval_order']: errors.append('field-evaluation-order')
    if set(d['omitted'])!=set(d['update_moved']): errors.append('update-omitted-only')
    if bool(set(d['explicit'])&set(d['update_written'])): errors.append('explicit-field-precedence')
    if d['cleanup_order']!=list(reversed(d['initialized_order'])): errors.append('construction-cleanup-order')
    if d['source_origins']!=d['lowered_origins']: errors.append('field-origin-preservation')
    if bool(set(d['exclusive_fields'])&set(d['spread_copies'])): errors.append('spread-exclusive-duplication')
    if d['tuple_source']!=d['tuple_lowered']: errors.append('tuple-slot-identity')
    if False: errors.append('enum-loan-discriminant')
    if not set(d['reference_slots'])<=set(d['remapped_slots']): errors.append('contained-reference-remap')
    if d['zero_field'] and bool(d['synthetic_loans']): errors.append('empty-aggregate-origin')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'source_order': [], 'eval_order': [], 'omitted': [], 'update_moved': [], 'explicit': [], 'update_written': [], 'initialized_order': [], 'cleanup_order': [], 'source_origins': {}, 'lowered_origins': {}, 'exclusive_fields': [], 'spread_copies': [], 'tuple_source': [], 'tuple_lowered': [], 'expected_variant': None, 'actual_variant': None, 'payload_loan': False, 'reference_slots': [], 'remapped_slots': [], 'zero_field': False, 'synthetic_loans': []}
check('well formed empty obligations',solve(base),[])
check('field-evaluation-order regression 0', solve(dict(base, **({'source_order':['a','b'],'eval_order':['b','a']}))), ['field-evaluation-order'])
check('field-evaluation-order regression 1', solve(dict(base, **({'source_order':[N,N+1],'eval_order':[N+1,N]}))), ['field-evaluation-order'])
check('update-omitted-only regression 0', solve(dict(base, **({'omitted':['a'],'update_moved':['a','b']}))), ['update-omitted-only'])
check('update-omitted-only regression 1', solve(dict(base, **({'omitted':[N],'update_moved':[N,N+1]}))), ['update-omitted-only'])
check('explicit-field-precedence regression 0', solve(dict(base, **({'explicit':['a'],'update_written':['a','b']}))), ['explicit-field-precedence'])
check('explicit-field-precedence regression 1', solve(dict(base, **({'explicit':[N],'update_written':[N,N+1]}))), ['explicit-field-precedence'])
check('construction-cleanup-order regression 0', solve(dict(base, **({'initialized_order':['a','b'],'cleanup_order':['a','b']}))), ['construction-cleanup-order'])
check('construction-cleanup-order regression 1', solve(dict(base, **({'initialized_order':[N,N+1],'cleanup_order':[N,N+1]}))), ['construction-cleanup-order'])
check('field-origin-preservation regression 0', solve(dict(base, **({'source_origins':{'a':'r'},'lowered_origins':{'a':'s'}}))), ['field-origin-preservation'])
check('field-origin-preservation regression 1', solve(dict(base, **({'source_origins':{'a':N},'lowered_origins':{'a':N+1}}))), ['field-origin-preservation'])
check('spread-exclusive-duplication regression 0', solve(dict(base, **({'exclusive_fields':['a'],'spread_copies':['a']}))), ['spread-exclusive-duplication'])
check('spread-exclusive-duplication regression 1', solve(dict(base, **({'exclusive_fields':[N],'spread_copies':[N]}))), ['spread-exclusive-duplication'])
check('tuple-slot-identity regression 0', solve(dict(base, **({'tuple_source':['a','b'],'tuple_lowered':['b','a']}))), ['tuple-slot-identity'])
check('tuple-slot-identity regression 1', solve(dict(base, **({'tuple_source':[N,N+1],'tuple_lowered':[N+1,N]}))), ['tuple-slot-identity'])
check('enum-loan-discriminant regression 0', solve(dict(base, **({'payload_loan':True,'actual_variant':'b','expected_variant':'a'}))), ['enum-loan-discriminant'])
check('enum-loan-discriminant regression 1', solve(dict(base, **({'payload_loan':True,'actual_variant':N+1,'expected_variant':N}))), ['enum-loan-discriminant'])
check('contained-reference-remap regression 0', solve(dict(base, **({'reference_slots':['a','b'],'remapped_slots':['a']}))), ['contained-reference-remap'])
check('contained-reference-remap regression 1', solve(dict(base, **({'reference_slots':[N,N+1],'remapped_slots':[N]}))), ['contained-reference-remap'])
check('empty-aggregate-origin regression 0', solve(dict(base, **({'zero_field':True,'synthetic_loans':['r']}))), ['empty-aggregate-origin'])
check('empty-aggregate-origin regression 1', solve(dict(base, **({'zero_field':True,'synthetic_loans':[N]}))), ['empty-aggregate-origin'])
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
well formed empty obligations[][]Passed
field-evaluation-order regression 0['field-evaluation-order']['field-evaluation-order']Passed
field-evaluation-order regression 1['field-evaluation-order']['field-evaluation-order']Passed
update-omitted-only regression 0['update-omitted-only']['update-omitted-only']Passed
update-omitted-only regression 1['update-omitted-only']['update-omitted-only']Passed
explicit-field-precedence regression 0['explicit-field-precedence']['explicit-field-precedence']Passed
explicit-field-precedence regression 1['explicit-field-precedence']['explicit-field-precedence']Passed
construction-cleanup-order regression 0['construction-cleanup-order']['construction-cleanup-order']Passed
construction-cleanup-order regression 1['construction-cleanup-order']['construction-cleanup-order']Passed
field-origin-preservation regression 0['field-origin-preservation']['field-origin-preservation']Passed
field-origin-preservation regression 1['field-origin-preservation']['field-origin-preservation']Passed
spread-exclusive-duplication regression 0['spread-exclusive-duplication']['spread-exclusive-duplication']Passed
spread-exclusive-duplication regression 1['spread-exclusive-duplication']['spread-exclusive-duplication']Passed
tuple-slot-identity regression 0['tuple-slot-identity']['tuple-slot-identity']Passed
tuple-slot-identity regression 1['tuple-slot-identity']['tuple-slot-identity']Passed
enum-loan-discriminant regression 0[]['enum-loan-discriminant']Failed
enum-loan-discriminant regression 1[]['enum-loan-discriminant']Failed
contained-reference-remap regression 0['contained-reference-remap']['contained-reference-remap']Passed
contained-reference-remap regression 1['contained-reference-remap']['contained-reference-remap']Passed
empty-aggregate-origin regression 0['empty-aggregate-origin']['empty-aggregate-origin']Passed
empty-aggregate-origin regression 1['empty-aggregate-origin']['empty-aggregate-origin']Passed

SHA-256 / b384f84ebcdfc0f895f6213d48da795a6f2975fecb7f94255d5af7f3c2aa1345

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(d):
    errors=[]
    if d['source_order']!=d['eval_order']: errors.append('field-evaluation-order')
    if set(d['omitted'])!=set(d['update_moved']): errors.append('update-omitted-only')
    if bool(set(d['explicit'])&set(d['update_written'])): errors.append('explicit-field-precedence')
    if d['cleanup_order']!=list(reversed(d['initialized_order'])): errors.append('construction-cleanup-order')
    if d['source_origins']!=d['lowered_origins']: errors.append('field-origin-preservation')
    if bool(set(d['exclusive_fields'])&set(d['spread_copies'])): errors.append('spread-exclusive-duplication')
    if d['tuple_source']!=d['tuple_lowered']: errors.append('tuple-slot-identity')
    if d['payload_loan'] and d['actual_variant'] is None: errors.append('enum-loan-discriminant')
    if not set(d['reference_slots'])<=set(d['remapped_slots']): errors.append('contained-reference-remap')
    if d['zero_field'] and bool(d['synthetic_loans']): errors.append('empty-aggregate-origin')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'source_order': [], 'eval_order': [], 'omitted': [], 'update_moved': [], 'explicit': [], 'update_written': [], 'initialized_order': [], 'cleanup_order': [], 'source_origins': {}, 'lowered_origins': {}, 'exclusive_fields': [], 'spread_copies': [], 'tuple_source': [], 'tuple_lowered': [], 'expected_variant': None, 'actual_variant': None, 'payload_loan': False, 'reference_slots': [], 'remapped_slots': [], 'zero_field': False, 'synthetic_loans': []}
check('well formed empty obligations',solve(base),[])
check('field-evaluation-order regression 0', solve(dict(base, **({'source_order':['a','b'],'eval_order':['b','a']}))), ['field-evaluation-order'])
check('field-evaluation-order regression 1', solve(dict(base, **({'source_order':[N,N+1],'eval_order':[N+1,N]}))), ['field-evaluation-order'])
check('update-omitted-only regression 0', solve(dict(base, **({'omitted':['a'],'update_moved':['a','b']}))), ['update-omitted-only'])
check('update-omitted-only regression 1', solve(dict(base, **({'omitted':[N],'update_moved':[N,N+1]}))), ['update-omitted-only'])
check('explicit-field-precedence regression 0', solve(dict(base, **({'explicit':['a'],'update_written':['a','b']}))), ['explicit-field-precedence'])
check('explicit-field-precedence regression 1', solve(dict(base, **({'explicit':[N],'update_written':[N,N+1]}))), ['explicit-field-precedence'])
check('construction-cleanup-order regression 0', solve(dict(base, **({'initialized_order':['a','b'],'cleanup_order':['a','b']}))), ['construction-cleanup-order'])
check('construction-cleanup-order regression 1', solve(dict(base, **({'initialized_order':[N,N+1],'cleanup_order':[N,N+1]}))), ['construction-cleanup-order'])
check('field-origin-preservation regression 0', solve(dict(base, **({'source_origins':{'a':'r'},'lowered_origins':{'a':'s'}}))), ['field-origin-preservation'])
check('field-origin-preservation regression 1', solve(dict(base, **({'source_origins':{'a':N},'lowered_origins':{'a':N+1}}))), ['field-origin-preservation'])
check('spread-exclusive-duplication regression 0', solve(dict(base, **({'exclusive_fields':['a'],'spread_copies':['a']}))), ['spread-exclusive-duplication'])
check('spread-exclusive-duplication regression 1', solve(dict(base, **({'exclusive_fields':[N],'spread_copies':[N]}))), ['spread-exclusive-duplication'])
check('tuple-slot-identity regression 0', solve(dict(base, **({'tuple_source':['a','b'],'tuple_lowered':['b','a']}))), ['tuple-slot-identity'])
check('tuple-slot-identity regression 1', solve(dict(base, **({'tuple_source':[N,N+1],'tuple_lowered':[N+1,N]}))), ['tuple-slot-identity'])
check('enum-loan-discriminant regression 0', solve(dict(base, **({'payload_loan':True,'actual_variant':'b','expected_variant':'a'}))), ['enum-loan-discriminant'])
check('enum-loan-discriminant regression 1', solve(dict(base, **({'payload_loan':True,'actual_variant':N+1,'expected_variant':N}))), ['enum-loan-discriminant'])
check('contained-reference-remap regression 0', solve(dict(base, **({'reference_slots':['a','b'],'remapped_slots':['a']}))), ['contained-reference-remap'])
check('contained-reference-remap regression 1', solve(dict(base, **({'reference_slots':[N,N+1],'remapped_slots':[N]}))), ['contained-reference-remap'])
check('empty-aggregate-origin regression 0', solve(dict(base, **({'zero_field':True,'synthetic_loans':['r']}))), ['empty-aggregate-origin'])
check('empty-aggregate-origin regression 1', solve(dict(base, **({'zero_field':True,'synthetic_loans':[N]}))), ['empty-aggregate-origin'])
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
well formed empty obligations[][]Passed
field-evaluation-order regression 0['field-evaluation-order']['field-evaluation-order']Passed
field-evaluation-order regression 1['field-evaluation-order']['field-evaluation-order']Passed
update-omitted-only regression 0['update-omitted-only']['update-omitted-only']Passed
update-omitted-only regression 1['update-omitted-only']['update-omitted-only']Passed
explicit-field-precedence regression 0['explicit-field-precedence']['explicit-field-precedence']Passed
explicit-field-precedence regression 1['explicit-field-precedence']['explicit-field-precedence']Passed
construction-cleanup-order regression 0['construction-cleanup-order']['construction-cleanup-order']Passed
construction-cleanup-order regression 1['construction-cleanup-order']['construction-cleanup-order']Passed
field-origin-preservation regression 0['field-origin-preservation']['field-origin-preservation']Passed
field-origin-preservation regression 1['field-origin-preservation']['field-origin-preservation']Passed
spread-exclusive-duplication regression 0['spread-exclusive-duplication']['spread-exclusive-duplication']Passed
spread-exclusive-duplication regression 1['spread-exclusive-duplication']['spread-exclusive-duplication']Passed
tuple-slot-identity regression 0['tuple-slot-identity']['tuple-slot-identity']Passed
tuple-slot-identity regression 1['tuple-slot-identity']['tuple-slot-identity']Passed
enum-loan-discriminant regression 0[]['enum-loan-discriminant']Failed
enum-loan-discriminant regression 1[]['enum-loan-discriminant']Failed
contained-reference-remap regression 0['contained-reference-remap']['contained-reference-remap']Passed
contained-reference-remap regression 1['contained-reference-remap']['contained-reference-remap']Passed
empty-aggregate-origin regression 0['empty-aggregate-origin']['empty-aggregate-origin']Passed
empty-aggregate-origin regression 1['empty-aggregate-origin']['empty-aggregate-origin']Passed

SHA-256 / 2bf3d0634a6bfcd5f91b32ec7bc4f90ff608901452eda636997580e055e2fa8c

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 21 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

The explicitly stated toy language is the complete scope; this is not a production compiler or a claim about Rust semantics. 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:44:09.167665+00:00.

Case digest / 9033637be625e6da4e5ab67e15f73761d1db884a934ba46d02e0fa4aaf4156eb