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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user