Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: possible error message improvement #4565
http://play.golang.org/p/87zosrj611 package main var x = 10 var y = 0.9 * x prog.go:4: constant 0.9 truncated to integer If you don't know that x is an int or that * requires both sides to have the same type, this is a bit of a leap. constant 0.9 truncated during conversion to type int (to match x) might be a little better.
I agree that it's a bit of a leap.
Compare that to the error when only variables are in the expression. It includes the expression and the types of the variables in question: https://play.golang.org/p/nfZ_xMultw
I like the idea of including (x) in the error message.
On the other hand, it's not always clear which variables are the cause when only variables are involved: https://play.golang.org/p/9_EchugdkA
So maybe there's a better way to do that error message as well. What comes to mind is the conversion syntax to indicate the types:
Here's a slightly more complex constants example where it might be nice if the error indicated that
This is my random issue today via CodeTriage.