fix: disallow newline in char literal

This commit is contained in:
zooster 2022-08-10 18:40:18 +02:00 committed by Andrew Kelley
parent 40447b25e8
commit 8fd20a5eb0

View File

@ -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(