Skip to content

Commit

Permalink
interp: fix operators working on integer constants
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mvertes authored Jan 14, 2021
1 parent 8ad14d8 commit 5c59dc4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
15 changes: 15 additions & 0 deletions _test/const22.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

const (
numDec uint8 = (1 << iota) / 2
numHex
numOct
numFloat
)

func main() {
println(13 & (numHex | numOct))
}

// Output:
// 1
29 changes: 17 additions & 12 deletions internal/cmd/genop/genop.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions interp/op.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c59dc4

Please sign in to comment.