mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
fix: disallow newline in char literal
This commit is contained in:
parent
40447b25e8
commit
8fd20a5eb0
@ -797,6 +797,10 @@ pub const Tokenizer = struct {
|
||||
remaining_code_units = 3;
|
||||
state = .char_literal_unicode;
|
||||
},
|
||||
'\n' => {
|
||||
result.tag = .invalid;
|
||||
break;
|
||||
},
|
||||
else => {
|
||||
state = .char_literal_end;
|
||||
},
|
||||
@ -1507,6 +1511,20 @@ test "tokenizer - code point literal with hex escape" {
|
||||
, &.{ .invalid, .invalid });
|
||||
}
|
||||
|
||||
test "tokenizer - newline in char literal" {
|
||||
try testTokenize(
|
||||
\\'
|
||||
\\'
|
||||
, &.{ .invalid, .invalid });
|
||||
}
|
||||
|
||||
test "tokenizer - newline in string literal" {
|
||||
try testTokenize(
|
||||
\\"
|
||||
\\"
|
||||
, &.{ .invalid, .string_literal });
|
||||
}
|
||||
|
||||
test "tokenizer - code point literal with unicode escapes" {
|
||||
// Valid unicode escapes
|
||||
try testTokenize(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user