diag: preserve factual source atomic-access diagnostics

This commit is contained in:
dev committed 2026-10-09 00:04:12 +03:00
1 parent ee09a7a290
commit edfef82cc6
18 files changed
+346 -9

No files matched your search

+56
View File
@@ -167,6 +167,62 @@ class CoverageFailures(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'missing diagnostic-identity use witness'):
self.verify_fake(row)
def atomic_load_pair(self):
row = self.fake_pair(source_path='source/reject_twins/ordinary_atomic_field_load.aji',
air_path='phase5/reject/ordinary_load.air')
row['required_ops'] = {'atomic.new': 1, 'load': 1, 'atomic.take': 1}
return row
def test_atomic_operand_identity_survives_field_and_ssa_renaming(self):
row = self.atomic_load_pair()
self.verify_fake(row)
p = self.corpus / 's.aji'
p.write_text(re.sub(r'\bcell\b', 'item', p.read_text()).replace('Holder', 'Wrapper'))
self.verify_fake(row)
def test_atomic_load_facts_preserve_scalar_and_borrow_mode(self):
original = (REAL_CORPUS / 'source/reject_twins/ordinary_atomic_field_load.aji').read_text()
for changed in (original.replace('u64', 'u8'),
original.replace('u64', 'bool').replace('0bool', 'false'),
original.replace('ref r = holder', 'mut r = holder')):
with self.subTest(source=changed):
row = self.atomic_load_pair()
p = self.corpus / 's.aji'
p.write_text(changed)
with self.assertRaisesRegex(ValueError, 'different offending operation/rule facts'):
self.verify_fake(row)
def test_another_atomic_borrow_cannot_replace_the_offending_operand(self):
row = self.atomic_load_pair()
p = self.corpus / 'a.air'
p.write_text(p.read_text().replace('%r = borrow.ref %c',
'%r = borrow.ref %c\n %other = borrow.ref %c\n borrow.end %other'))
real_command = twins.command
def changed(aji, *args, status):
result = real_command(aji, *args, status=status)
if args[0] == 'check' and Path(args[1]) == p:
ds = [json.loads(line) for line in result.splitlines()]
ds[0]['operand'] = '%other'
return '\n'.join(json.dumps(d) for d in ds) + '\n'
return result
with patch.object(twins, 'command', changed):
with self.assertRaisesRegex(ValueError, 'atomic operand is not the offending load operand'):
self.verify_fake(row)
def test_atomic_source_raw_identity_mapping_stays_exact(self):
row = self.atomic_load_pair()
real_command = twins.command
def changed(aji, *args, status):
result = real_command(aji, *args, status=status)
if args[0] == 'check' and Path(args[1]) == self.corpus / 's.aji':
ds = [json.loads(line) for line in result.splitlines()]
ds[0]['operand'] = '%wrong'
return '\n'.join(json.dumps(d) for d in ds) + '\n'
return result
with patch.object(twins, 'command', changed):
with self.assertRaisesRegex(ValueError, 'mapping changed diagnostic identities'):
self.verify_fake(row)
def test_endpoint_rule_cannot_substitute_mutex_for_channel_creation(self):
row = self.fake_pair(source_path='source/reject_twins/channel_endpoint_element.aji',
air_path='phase3/reject/channels_endpoint_element.air')