cli: parse qualified constructor paths iteratively

This commit is contained in:
dev committed 2026-10-10 19:23:50 +03:00
1 parent d39a422b2b
commit 371329f3f0
5 files changed
+227 -12

No files matched your search

+20
View File
@@ -244,6 +244,26 @@ with tempfile.TemporaryDirectory(prefix='aji-expression-depth-') as directory:
for command in ('lower', 'run', 'report', 'explore'):
assert json.loads(cli(command, path, code=1)) == error
# Parser.exprPath is used by qualified enum/struct constructors, including
# explicit type arguments. Unknown names must reach lowering rather than
# exhausting the native stack, with their full spelling and original span.
for depth in (16, 1024, 16384, 65536):
name = 'ns.' * depth + 'Record'
header = 'fn main() -> i64 effects [] { return '
for kind, suffix, message in (
('variant', '::A', 'unknown enum'),
('struct', ' { field: 1u64 }', 'unknown type'),
('generic-variant', '::<u64>::A', 'unknown or inaccessible generic type'),
('generic-struct', '::<u64> { field: 1u64 }', 'unknown or inaccessible generic type'),
):
path = root / f'qualified-{kind}-{depth}.aji'
path.write_text('module depth\n' + header + name + suffix + '; }\n')
error = json.loads(cli('check', path, code=1))
assert (error['code'], error['name'], error['file'], error['line'], error['col'], error['message']) == (
'E7002', name, str(path), 2, len(header) + 1, message), error
for command in ('lower', 'run', 'report', 'explore'):
assert json.loads(cli(command, path, code=1)) == error
# Signed boundary literal remains one negative constant; the outer
# checked negation traps rather than changing literal acceptance.
minimum = root / 'minimum.aji'