mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
parser: require expression after colon in slice expr
This commit is contained in:
parent
4758752e5d
commit
d26d696ee0
@ -3257,7 +3257,7 @@ const Parser = struct {
|
||||
if (p.eatToken(.ellipsis2)) |_| {
|
||||
const end_expr = try p.parseExpr();
|
||||
if (p.eatToken(.colon)) |_| {
|
||||
const sentinel = try p.parseExpr();
|
||||
const sentinel = try p.expectExpr();
|
||||
_ = try p.expectToken(.r_bracket);
|
||||
return p.addNode(.{
|
||||
.tag = .slice_sentinel,
|
||||
|
||||
@ -5118,6 +5118,14 @@ test "zig fmt: while continue expr" {
|
||||
});
|
||||
}
|
||||
|
||||
test "zig fmt: error for missing sentinel value in sentinel slice" {
|
||||
try testError(
|
||||
\\const foo = foo[0..:];
|
||||
, &[_]Error{
|
||||
.expected_expr,
|
||||
});
|
||||
}
|
||||
|
||||
test "zig fmt: error for invalid bit range" {
|
||||
try testError(
|
||||
\\var x: []align(0:0:0)u8 = bar;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user