Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type mismatch of shift on untyped expression #927

Closed
mvertes opened this issue Oct 23, 2020 · 0 comments · Fixed by #930
Closed

type mismatch of shift on untyped expression #927

mvertes opened this issue Oct 23, 2020 · 0 comments · Fixed by #930
Assignees
Labels
area/core bug Something isn't working
Milestone

Comments

@mvertes
Copy link
Member

mvertes commented Oct 23, 2020

The following program sample.go triggers a panic:

package main

func main() {
    var max, a, b uint32
    max = a + (1 << b)
    println(max) 
}

Expected result:

$ go run ./sample.go
1

Got:

$ yaegi ./sample.go
./sample.go:4:6: panic
run: reflect: call of reflect.Value.Uint on int Value
goroutine 1 [running]:
runtime/debug.Stack(0x1, 0xc0002f4600, 0x40)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0x9f
github.com/traefik/yaegi/interp.(*Interpreter).eval.func1(0xc000217c70)
        /home/marc/go/src/github.com/traefik/yaegi/interp/interp.go:480 +0xc5
panic(0xe01b60, 0xc00010ef00)
        /usr/lib/go/src/runtime/panic.go:969 +0x1b9
github.com/traefik/yaegi/interp.runCfg.func1(0xc0003780a0, 0xc00012cc00)
        /home/marc/go/src/github.com/traefik/yaegi/interp/run.go:124 +0x217
panic(0xe01b60, 0xc00010ef00)
        /usr/lib/go/src/runtime/panic.go:969 +0x1b9
reflect.Value.Uint(...)
        /usr/lib/go/src/reflect/value.go:1941
github.com/traefik/yaegi/interp.genValueUint.func2(0xc0003780a0, 0xdcdc60, 0xc00011fae4, 0x18a, 0x0)
        /home/marc/go/src/github.com/traefik/yaegi/interp/value.go:436 +0xfd
github.com/traefik/yaegi/interp.add.func9(0xc0003780a0, 0xc000434c60)
        /home/marc/go/src/github.com/traefik/yaegi/interp/op.go:95 +0x6b
github.com/traefik/yaegi/interp.runCfg(0xc00012cc00, 0xc0003780a0)
        /home/marc/go/src/github.com/traefik/yaegi/interp/run.go:130 +0x6e
github.com/traefik/yaegi/interp.(*Interpreter).run(0xc000372000, 0xc00012c400, 0xc000378000)
        /home/marc/go/src/github.com/traefik/yaegi/interp/run.go:108 +0x2af
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc000372000, 0xc00012f5c0, 0x56, 0x7fff3c07a4d1, 0x17, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/marc/go/src/github.com/traefik/yaegi/interp/interp.go:572 +0x809
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc000372000, 0x7fff3c07a4d1, 0x17, 0xc00012f500, 0x56, 0x0, 0x0, 0xc000123110)
        /home/marc/go/src/github.com/traefik/yaegi/interp/interp.go:394 +0xfa
main.runFile(0xc000372000, 0x7fff3c07a4d1, 0x17, 0xc000116240, 0x1)
        /home/marc/go/src/github.com/traefik/yaegi/cmd/yaegi/run.go:123 +0xae
main.run(0xc00000e090, 0x1, 0x1, 0x13, 0x13)
        /home/marc/go/src/github.com/traefik/yaegi/cmd/yaegi/run.go:89 +0x7e5
main.main()
        /home/marc/go/src/github.com/traefik/yaegi/cmd/yaegi/yaegi.go:144 +0x415
@mvertes mvertes added bug Something isn't working area/core labels Oct 23, 2020
@mvertes mvertes added this to the v0.9.x milestone Oct 23, 2020
@mvertes mvertes self-assigned this Oct 23, 2020
mvertes added a commit that referenced this issue Oct 29, 2020
A non-constant shift expression can be untyped, requiring to apply a
type from inherited context. This change insures that such context is
propagated during CFG pre-order walk, to be used if necessary.

Fixes #927.
mvertes added a commit that referenced this issue Oct 29, 2020
A non-constant shift expression can be untyped, requiring to apply a
type from inherited context. This change insures that such context is
propagated during CFG pre-order walk, to be used if necessary.

Fixes #927.
traefiker pushed a commit that referenced this issue Nov 2, 2020
A non-constant shift expression can be untyped, requiring to apply a
type from inherited context. This change insures that such context is
propagated during CFG pre-order walk, to be used if necessary.

Fixes #927.
traefiker pushed a commit that referenced this issue Nov 2, 2020
A non-constant shift expression can be untyped, requiring to apply a
type from inherited context. This change insures that such context is
propagated during CFG pre-order walk, to be used if necessary.
    
Fixes #927.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core bug Something isn't working
Projects
None yet
1 participant