Can't have negative floats
Author: wolffgCreated May 1, 2026Updated Sep 17, 2026
Labelstoolchain
Description of the bug:
Tried to subtract a float from a float, or have a negative float, and it errored out.
What did you do, or what's a simple way to reproduce the bug?
https://carbon.compiler-explorer.com/z/fPGeeqvj8
What did you expect to happen?
Have a negative value, or do subtraction.
What actually happened?
:8:55: error: cannot access member of interface Core.Negate in type Core.FloatLiteral that does not implement that interface
var ne_point: AnInitializeablePoint = {.x = 1.0, .y = -1.0};
^~~~
:9:46: error: cannot access member of interface Core.SubWith(Core.FloatLiteral) in type Core.FloatLiteral that does not implement that interface
var sw_point: AnInitializeablePoint = {.x = (0.0 - 1.0), .y = 1.0};
^~~~~~~~~
Any other information, logs, or outputs that you want to share?
class AnInitializeablePoint {
var x: f64;
var y: f64;
}
var ne_point: AnInitializeablePoint = {.x = 1.0, .y = -1.0};
var sw_point: AnInitializeablePoint = {.x = (0.0 - 1.0), .y = 1.0};
Source: carbon-language/carbon-lang