AstGen: disallow '-0' integer literal
The intent here is ambiguous: this resolves to the comptime_int '0', but it's likely the user meant to use a floating-point literal. Resolves: #16890
This commit is contained in:
11
test/cases/compile_errors/negative_zero_literal.zig
Normal file
11
test/cases/compile_errors/negative_zero_literal.zig
Normal file
@@ -0,0 +1,11 @@
|
||||
export fn foo() void {
|
||||
_ = -0;
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:10: error: integer literal '-0' is ambiguous
|
||||
// :2:10: note: use '0' for an integer zero
|
||||
// :2:10: note: use '-0.0' for a floating-point signed zero
|
||||
Reference in New Issue
Block a user