std.zig: fix integer overflows during parsing

these were found while fuzzing zls.

this patch prevents overflow for the following file contents and adds
tests for them.
	* `enum(u32)` - causes overflow in std.zig.Ast.fullContainerDecl()
	* `*x` - causes overflow in std.zig.Ast.fullPtrType()
	* `**x` - causes overflow in std.zig.Ast.firstToken()
This commit is contained in:
travisstaloch
2022-12-20 07:33:40 -08:00
committed by GitHub
parent 3a1295cd6f
commit 4aa8462cc9
2 changed files with 27 additions and 3 deletions

View File

@@ -221,6 +221,27 @@ test "zig fmt: top-level tuple function call type" {
);
}
test "zig fmt: top-level enum missing 'const name ='" {
try testError(
\\enum(u32)
\\
, &[_]Error{.expected_token});
}
test "zig fmt: top-level bare asterisk+identifier" {
try testCanonical(
\\*x
\\
);
}
test "zig fmt: top-level bare asterisk+asterisk+identifier" {
try testCanonical(
\\**x
\\
);
}
test "zig fmt: C style containers" {
try testError(
\\struct Foo {