frontend: collect independent source diagnostics without cascades
This commit is contained in:
1 parent
2c6c7a3dcd
commit
4cda44823d
47 files changed
+697
-44
No files matched your search
@@ -26,7 +26,6 @@ with tempfile.TemporaryDirectory(prefix='aji-reasons-') as d:
|
||||
('move_copy', 'struct S{x:u64} fn main()->u64 effects [] {let x=S{x:1u64};let y=move x;return 0u64;}'),
|
||||
('move_copy', 'fn main()->u64 effects [] {let x=[1u64;2];let y=move x;return 0u64;}'),
|
||||
('move_borrow', 'fn main()->u64 effects [] {let x=1u64;ref p=x;return move p;}'),
|
||||
('invalid_move', 'fn f(x:void)->u64 effects [] {return move x;} fn main()->u64 effects [] {0u64}'),
|
||||
('loop_control_outside_loop', 'fn main()->void effects [] {break;}'),
|
||||
('zero_not_zeroable', 'fn main()->u64 effects [] {var x:own<u64> = zero;return 0u64;}'),
|
||||
('value_block_statement', 'fn main()->i64 effects [] {{2i64} -3i64}'),
|
||||
@@ -48,6 +47,15 @@ with tempfile.TemporaryDirectory(prefix='aji-reasons-') as d:
|
||||
assert json.loads(invoke('lower', path, code=1)) == error
|
||||
assert invoke('check', path, code=1) == invoke('check', path, code=1)
|
||||
|
||||
# Void parameters are rejected by annotation validation before body
|
||||
# lowering; this must never be attributed to an invalid_move body error.
|
||||
invalid_parameter = root / 'void-parameter.aji'
|
||||
invalid_parameter.write_text('module reasons\nfn f(x:void)->u64 effects [] {return move x;} '
|
||||
'fn main()->u64 effects [] {0u64}\n')
|
||||
error = json.loads(invoke('check', invalid_parameter, code=1))
|
||||
assert (error['code'], error['position'], error['type_constructor']) == ('E7005', 'param', 'void'), error
|
||||
assert 'reason' not in error and json.loads(invoke('lower', invalid_parameter, code=1)) == error
|
||||
|
||||
# Copy substitution in a generic transfer is permitted, not a Copy-move
|
||||
# diagnostic. Borrowed substitution still rejects with its own reason.
|
||||
valid = root / 'generic.aji'
|
||||
@@ -82,7 +90,8 @@ with tempfile.TemporaryDirectory(prefix='aji-reasons-') as d:
|
||||
# Exercise all public standalone E7006 fixtures, without visiting any
|
||||
# benchmark corpus or unrelated untracked directory.
|
||||
registry = (REPO / 'docs/reference/error-codes.md').read_text()
|
||||
reasons = set(re.findall(r'^\| `([a-z_]+)` \|', registry, re.M))
|
||||
reason_section = registry.split('## E7006 reasons\n', 1)[1].split('\n## ', 1)[0]
|
||||
reasons = set(re.findall(r'^\| `([a-z_]+)` \|', reason_section, re.M))
|
||||
fixtures = 0
|
||||
for path in sorted((REPO / 'tests/conformance/source').rglob('*.aji')):
|
||||
if not re.search(r'^// expect: reject E7006\s*$', path.read_text(), re.M):
|
||||
|
||||
Reference in new issue
Block a user