| author | |
| committer | |
| log | d26d696ee01d3a17d17cde24c8841e7f551ba5f2 |
| tree | 96b165fba9084df59da2e2c4a83420787d6d4798 |
| parent | 4758752e5d64a3e36086483de569188f62519bac |
2 files changed, 9 insertions(+), 1 deletions(-)
lib/std/zig/parse.zig+1-1| ... | @@ -3257,7 +3257,7 @@ const Parser = struct { | ... | @@ -3257,7 +3257,7 @@ const Parser = struct { |
| 3257 | if (p.eatToken(.ellipsis2)) |_| { | 3257 | if (p.eatToken(.ellipsis2)) |_| { |
| 3258 | const end_expr = try p.parseExpr(); | 3258 | const end_expr = try p.parseExpr(); |
| 3259 | if (p.eatToken(.colon)) |_| { | 3259 | if (p.eatToken(.colon)) |_| { |
| 3260 | const sentinel = try p.parseExpr(); | 3260 | const sentinel = try p.expectExpr(); |
| 3261 | _ = try p.expectToken(.r_bracket); | 3261 | _ = try p.expectToken(.r_bracket); |
| 3262 | return p.addNode(.{ | 3262 | return p.addNode(.{ |
| 3263 | .tag = .slice_sentinel, | 3263 | .tag = .slice_sentinel, |
lib/std/zig/parser_test.zig+8| ... | @@ -5118,6 +5118,14 @@ test "zig fmt: while continue expr" { | ... | @@ -5118,6 +5118,14 @@ test "zig fmt: while continue expr" { |
| 5118 | }); | 5118 | }); |
| 5119 | } | 5119 | } |
| 5120 | 5120 | ||
| 5121 | test "zig fmt: error for missing sentinel value in sentinel slice" { | ||
| 5122 | try testError( | ||
| 5123 | \\const foo = foo[0..:]; | ||
| 5124 | , &[_]Error{ | ||
| 5125 | .expected_expr, | ||
| 5126 | }); | ||
| 5127 | } | ||
| 5128 | |||
| 5121 | test "zig fmt: error for invalid bit range" { | 5129 | test "zig fmt: error for invalid bit range" { |
| 5122 | try testError( | 5130 | try testError( |
| 5123 | \\var x: []align(0:0:0)u8 = bar; | 5131 | \\var x: []align(0:0:0)u8 = bar; |