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/go: regression compiling "const X = string(rune(31))" #34563
Given this file:
package stringrune const X = string(rune(31))
It compiled successfully with
So I used git bisect to determine that 581526c (cmd/compile: rewrite untyped constant conversion logic) was the Go commit where it stopped compiling.
I skimmed through the spec and I wasn't able to quickly determine whether the current or previous behavior was conformant.
This particular line exists in the wild, in influxdb: https://github.com/influxdata/influxdb/blob/99ef5fb3e44400bcc49383035ab7c81bd7be4979/services/continuous_querier/service.go#L28. I have no context on why it was written like that instead of a string literal
The issue is evconst wasn't performing constant folding for integer->string conversions.
This used to not be a problem because convertlit1 would internally handle constant folding for explicit conversions, but 581526c changed convertlit1 to short-circuit if the operand is already typed, expecting that evconst would handle this instead.