You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ go build
toolchain.go:131:24: syntax error: cannot use assignment (gotoolchain) = ("path") as value
The code only says if gotoolchain = "path" {, a typo of = for ==.
I am not sure what the parens mean in this error message.
Every time I see them (apparently I do this with some frequency)
it is a bit jarring, almost like they are single-element tuples,
but then I remember Go has no tuples, at least not parenthesized ones like Python.
It would be better not to show them:
toolchain.go:131:24: syntax error: cannot use assignment gotoolchain = "path" as value
Or maybe:
toolchain.go:131:24: syntax error: cannot use assignment as value: gotoolchain = "path"
There's explicit code in the parser to emphasize the LHS and RHS for this kind of error:
// A common syntax error is to write '=' instead of '==',// which turns an expression into an assignment. Provide// a more explicit error message in that case to prevent// further confusion.varstrstringifas, ok:=s.(*AssignStmt); ok&&as.Op==0 {
// Emphasize Lhs and Rhs of assignment with parentheses to highlight '='.// Do it always - it's not worth going through the trouble of doing it// only for "complex" left and right sides.str="assignment ("+String(as.Lhs) +") = ("+String(as.Rhs) +")"
} else {
str=String(s)
}
This is trivially changed (or even removed), but we should be conscious of the issue. Without the special casing, the error for
package p
func_(x, yint) {
ifx=y {}
}
will be:
syntax error: cannot use x = y as value
This is problematic when the LHS and RHS are more complex as in x || y = z where we want to emphasize x || y as the LHS. But perhaps the parentheses logic should just apply of a side is complex.
The code only says
if gotoolchain = "path" {
, a typo of=
for==
.I am not sure what the parens mean in this error message.
Every time I see them (apparently I do this with some frequency)
it is a bit jarring, almost like they are single-element tuples,
but then I remember Go has no tuples, at least not parenthesized ones like Python.
It would be better not to show them:
Or maybe:
/cc @griesemer
The text was updated successfully, but these errors were encountered: