air: fix out-of-bounds on type line without a name

Found by mutation fuzzing of the conformance corpus through `aji check`
and `aji run` (6000 mutants, no remaining crashes). Adds a regression
test.
This commit is contained in:
dev committed 2026-10-04 12:32:24 +03:00
1 parent 1f5008bb37
commit 8ca93d0fa6
1 file changed
+5 -1
+5 -1
View File
@@ -292,7 +292,10 @@ const Parser = struct {
p.skipNewlines();
if (p.peek().tag == .eof) break;
if (p.atWord("type")) {
p.types[ti] = try p.parseTypeDecl();
// Parse before indexing: a malformed declaration was not
// counted by the pre-scan and fails inside parseTypeDecl.
const d = try p.parseTypeDecl();
p.types[ti] = d;
ti += 1;
} else if (p.atWord("fn")) {
p.skipFunction();
@@ -965,6 +968,7 @@ test "resolution diagnostics" {
try expectCodes(header ++ "fn @f() -> u8\neffects []\nentry:\n trap\nfn @f() -> u8\neffects []\nentry:\n trap\n", &.{"E0003"});
try expectCodes("module t\nair 1\nlang 0.1\nfeatures []\n", &.{"E0005"});
try expectCodes(header ++ "fn @f( -> u8\n", &.{"E0001"});
try expectCodes(header ++ "type\n", &.{"E0001"}); // found by fuzzing
}
test "integer literal ranges" {