cli: query field annotations iteratively and close type-depth audit
This commit is contained in:
1 parent
d98ddbc073
commit
46bd29953f
6 files changed
+291
-10
No files matched your search
@@ -85,4 +85,27 @@ with tempfile.TemporaryDirectory(prefix='aji-nominal-queries-') as directory:
|
||||
assert (record['code'], record['file'], record['line']) == ('E1003', 'nodes.aji', 2), record
|
||||
assert record['type'].endswith('N0'), record
|
||||
|
||||
# A shallow field expression must not recursively walk its deep annotation
|
||||
# in the best-effort type query used by `.len`. Main executes only a scalar;
|
||||
# these probes exercise compiler paths, not materialization of deep values.
|
||||
for depth in (16384, 65536):
|
||||
annotation = '[' * depth + 'u8' + ';1]' * depth
|
||||
source = root / f'field-type-{depth}.aji'
|
||||
source.write_text('module field.types\nstruct Record { x: ' + annotation + ' }\n'
|
||||
'fn size(r: Record) -> usize effects [] { r.x.len }\n'
|
||||
'fn main() -> u64 effects [] { 42u64 }\n')
|
||||
cli('check', source)
|
||||
lowered = cli('lower', source)
|
||||
assert 'const.usize 1' in lowered, lowered[-200:]
|
||||
raw = root / f'field-type-{depth}.air'
|
||||
raw.write_text(lowered)
|
||||
cli('check', raw)
|
||||
formatted = root / f'field-type-{depth}-formatted.aji'
|
||||
formatted.write_text(cli('fmt', source))
|
||||
cli('fmt', '--check', formatted)
|
||||
assert cli('lower', formatted) == lowered
|
||||
assert json.loads(cli('run', '--fuel', '100', source))['value'] == 42
|
||||
assert json.loads(cli('run', '--fuel', '100', raw))['value'] == 42
|
||||
assert json.loads(cli('report', source)) == json.loads(cli('report', raw))
|
||||
|
||||
print(f'nominal query CLI integration passed ({checks} checks)')
|
||||
Reference in new issue
Block a user