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:
1 parent
1f5008bb37
commit
8ca93d0fa6
1 file changed
+5
-1
+5
-1
@@ -292,7 +292,10 @@ const Parser = struct {
|
|||||||
p.skipNewlines();
|
p.skipNewlines();
|
||||||
if (p.peek().tag == .eof) break;
|
if (p.peek().tag == .eof) break;
|
||||||
if (p.atWord("type")) {
|
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;
|
ti += 1;
|
||||||
} else if (p.atWord("fn")) {
|
} else if (p.atWord("fn")) {
|
||||||
p.skipFunction();
|
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(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("module t\nair 1\nlang 0.1\nfeatures []\n", &.{"E0005"});
|
||||||
try expectCodes(header ++ "fn @f( -> u8\n", &.{"E0001"});
|
try expectCodes(header ++ "fn @f( -> u8\n", &.{"E0001"});
|
||||||
|
try expectCodes(header ++ "type\n", &.{"E0001"}); // found by fuzzing
|
||||||
}
|
}
|
||||||
|
|
||||||
test "integer literal ranges" {
|
test "integer literal ranges" {
|
||||||
|
|||||||
Reference in new issue
Block a user