cmd/dist has a small //go:build constraint parser and evaluator for the needs of bootstrapping. Back when it was added (CL 359314, CC @rsc), go/build/constraint couldn't be used because cmd/dist needed to be able to be built with much older Go releases, so an implementation was added.
@cuiweixie noticed and reported that the precedence && and || appeared wrong in a golang-dev message at https://groups.google.com/g/golang-dev/c/0k7jlbEV29o/m/3cfUZHrpCAAJ, causing gccgo && gc || gc to evaluate to false (given gc is set, gccgo is not set), though it should be true.
It can be fixed with:
- {tok: "&&", prec: 1, infix: func(x, y val) val { return x && y }},
- {tok: "||", prec: 2, infix: func(x, y val) val { return x || y }},
+ {tok: "||", prec: 1, infix: func(x, y val) val { return x || y }},
+ {tok: "&&", prec: 2, infix: func(x, y val) val { return x && y }},
Though it's also possible to start using go/build/constraint now and delete the parser copy. A stack ending with CL 773823 does that.
CC @cuiweixie, @adonovan.
cmd/dist has a small //go:build constraint parser and evaluator for the needs of bootstrapping. Back when it was added (CL 359314, CC @rsc), go/build/constraint couldn't be used because cmd/dist needed to be able to be built with much older Go releases, so an implementation was added.
@cuiweixie noticed and reported that the precedence && and || appeared wrong in a golang-dev message at https://groups.google.com/g/golang-dev/c/0k7jlbEV29o/m/3cfUZHrpCAAJ, causing
gccgo && gc || gcto evaluate to false (givengcis set,gccgois not set), though it should be true.It can be fixed with:
Though it's also possible to start using go/build/constraint now and delete the parser copy. A stack ending with CL 773823 does that.
CC @cuiweixie, @adonovan.