mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
make parsing 0.0_e1 an error
This commit is contained in:
parent
7aac21c6f5
commit
925f710852
2 changed files with 16 additions and 0 deletions
|
|
@ -1229,6 +1229,10 @@ void tokenize(Buf *buf, Tokenization *out) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (is_exponent_signifier(c, t.radix)) {
|
if (is_exponent_signifier(c, t.radix)) {
|
||||||
|
if (t.is_trailing_underscore) {
|
||||||
|
invalid_char_error(&t, c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (t.radix != 16 && t.radix != 10) {
|
if (t.radix != 16 && t.radix != 10) {
|
||||||
invalid_char_error(&t, c);
|
invalid_char_error(&t, c);
|
||||||
}
|
}
|
||||||
|
|
@ -1296,6 +1300,10 @@ void tokenize(Buf *buf, Tokenization *out) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (is_exponent_signifier(c, t.radix)) {
|
if (is_exponent_signifier(c, t.radix)) {
|
||||||
|
if (t.is_trailing_underscore) {
|
||||||
|
invalid_char_error(&t, c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
t.state = TokenizeStateFloatExponentUnsigned;
|
t.state = TokenizeStateFloatExponentUnsigned;
|
||||||
t.radix = 10; // exponent is always base 10
|
t.radix = 10; // exponent is always base 10
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -485,6 +485,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
"tmp.zig:2:23: error: invalid character: '_'",
|
"tmp.zig:2:23: error: invalid character: '_'",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cases.add("invalid underscore placement in float literal - 14",
|
||||||
|
\\fn main() void {
|
||||||
|
\\ var bad: f128 = 0x0.0_p1;
|
||||||
|
\\})
|
||||||
|
, &[_][]const u8{
|
||||||
|
"tmp.zig:2:27: error: invalid character: 'p'",
|
||||||
|
});
|
||||||
|
|
||||||
cases.add("var args without c calling conv",
|
cases.add("var args without c calling conv",
|
||||||
\\fn foo(args: ...) void {}
|
\\fn foo(args: ...) void {}
|
||||||
\\comptime {
|
\\comptime {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue