Skip to content

Commit

Permalink
interp: fix type check in constant unary operations
Browse files Browse the repository at this point in the history
In unary constant operations, the test for unsigned was defeated by
testing for int first, which is true also for unsigned. Make sure that
testing for unsigned precedes testing for int.

Fixes #907.
  • Loading branch information
mvertes authored Oct 19, 2020
1 parent f6d8261 commit 804664c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
12 changes: 12 additions & 0 deletions _test/const20.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import "fmt"

const maxLen = int64(int(^uint(0) >> 1))

func main() {
fmt.Println(maxLen)
}

// Output:
// 9223372036854775807
4 changes: 2 additions & 2 deletions internal/cmd/genop/genop.go

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

12 changes: 6 additions & 6 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 804664c

Please sign in to comment.