| author | |
| committer | |
| log | 925f71085269a8072ea9c49025a534fa47fbec44 |
| tree | a42906884ea7db33ba7ff07b26a3666d847feb16 |
| parent | 7aac21c6f59b70deea6ced617f7b6a550e92bab4 |
2 files changed, 16 insertions(+), 0 deletions(-)
src/tokenizer.cpp+8| ... | ... | @@ -1229,6 +1229,10 @@ void tokenize(Buf *buf, Tokenization *out) { |
| 1229 | 1229 | break; |
| 1230 | 1230 | } |
| 1231 | 1231 | if (is_exponent_signifier(c, t.radix)) { |
| 1232 | if (t.is_trailing_underscore) { | |
| 1233 | invalid_char_error(&t, c); | |
| 1234 | break; | |
| 1235 | } | |
| 1232 | 1236 | if (t.radix != 16 && t.radix != 10) { |
| 1233 | 1237 | invalid_char_error(&t, c); |
| 1234 | 1238 | } |
| ... | ... | @@ -1296,6 +1300,10 @@ void tokenize(Buf *buf, Tokenization *out) { |
| 1296 | 1300 | break; |
| 1297 | 1301 | } |
| 1298 | 1302 | if (is_exponent_signifier(c, t.radix)) { |
| 1303 | if (t.is_trailing_underscore) { | |
| 1304 | invalid_char_error(&t, c); | |
| 1305 | break; | |
| 1306 | } | |
| 1299 | 1307 | t.state = TokenizeStateFloatExponentUnsigned; |
| 1300 | 1308 | t.radix = 10; // exponent is always base 10 |
| 1301 | 1309 | break; |
test/compile_errors.zig+8| ... | ... | @@ -485,6 +485,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 485 | 485 | "tmp.zig:2:23: error: invalid character: '_'", |
| 486 | 486 | }); |
| 487 | 487 | |
| 488 | cases.add("invalid underscore placement in float literal - 14", | |
| 489 | \\fn main() void { | |
| 490 | \\ var bad: f128 = 0x0.0_p1; | |
| 491 | \\}) | |
| 492 | , &[_][]const u8{ | |
| 493 | "tmp.zig:2:27: error: invalid character: 'p'", | |
| 494 | }); | |
| 495 | ||
| 488 | 496 | cases.add("var args without c calling conv", |
| 489 | 497 | \\fn foo(args: ...) void {} |
| 490 | 498 | \\comptime { |