Skip to content

Commit 5c59dc4

Browse files
authored
interp: fix operators working on integer constants
Always attempt to obtain an integer constant value for operators expecting so. It allows to use '/' in integer constant defintions, instead of default big.Rat. Fixes #1005
1 parent 8ad14d8 commit 5c59dc4

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

_test/const22.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
const (
4+
numDec uint8 = (1 << iota) / 2
5+
numHex
6+
numOct
7+
numFloat
8+
)
9+
10+
func main() {
11+
println(13 & (numHex | numOct))
12+
}
13+
14+
// Output:
15+
// 1

internal/cmd/genop/genop.go

Lines changed: 17 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interp/op.go

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)