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

reflect: call of reflect.Value.Uint on int Value #1653

Closed
ISNing opened this issue Jul 27, 2024 · 0 comments · Fixed by #1654
Closed

reflect: call of reflect.Value.Uint on int Value #1653

ISNing opened this issue Jul 27, 2024 · 0 comments · Fixed by #1654
Labels
area/core bug Something isn't working

Comments

@ISNing
Copy link

ISNing commented Jul 27, 2024

The following program sample.go triggers an unexpected result

package main

func f(b uint) uint {
        return uint(1) + (0x1 >> b)
}

func main() {
    println(f(1))
}

Expected result

$ go run ./sample.go
1

Got

$ yaegi ./sample.go
./sample.go:4:9: panic: main.f(...)
./sample.go:8:13: panic: main.main(...)
run: reflect: call of reflect.Value.Uint on int Value
goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/go-1.21/src/runtime/debug/stack.go:24 +0x5e
github.com/traefik/yaegi/interp.(*Interpreter).Execute.func1()
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/program.go:146 +0x7e
panic({0xdbe800?, 0xc0004de420?})
        /usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
github.com/traefik/yaegi/interp.runCfg.func1()
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:226 +0x177
panic({0xdbe800?, 0xc0004de420?})
        /usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
github.com/traefik/yaegi/interp.runCfg.func1()
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:226 +0x177
panic({0xdbe800?, 0xc0004de420?})
        /usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
reflect.Value.Uint(...)
        /usr/lib/go-1.21/src/reflect/value.go:2692
github.com/traefik/yaegi/interp.genValueUint.func2(0xd86580?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/value.go:482 +0xaf
github.com/traefik/yaegi/interp.add.func10(0x4717d3?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/op.go:104 +0x3a
github.com/traefik/yaegi/interp.runCfg(0xc00070c500, 0xc0000f2630, 0xc00033b930?, 0xd86780?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:234 +0x285
github.com/traefik/yaegi/interp.call.func9(0xc0000f2580)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:1401 +0x7ec
github.com/traefik/yaegi/interp.runCfg(0xc00070da40, 0xc0000f2580, 0xc00033b9b8?, 0x0?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:234 +0x285
github.com/traefik/yaegi/interp.(*Interpreter).run(0xc000105440, 0xc00070cdc0, 0xc0000f2420?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/run.go:119 +0x3c5
github.com/traefik/yaegi/interp.(*Interpreter).Execute(0xc000105440, 0xc00031d320)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/program.go:172 +0x225
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc000105440, {0xc0000b6150?, 0x66?}, {0x7ffd2df11a23?, 0x200?}, 0x0?)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:563 +0x55
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc000105440, {0x7ffd2df11a23, 0xb})
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:512 +0xa6
main.runFile(0x7ffd2df11a23?, {0x7ffd2df11a23, 0xb}, 0x0)
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/run.go:153 +0xd7
main.run({0xc000036050?, 0x1, 0x1})
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/run.go:116 +0xb97
main.main()
        /home/isning/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/yaegi.go:144 +0x2af

Yaegi Version

v0.16.1

Additional Notes

No response

@mvertes mvertes added bug Something isn't working area/core labels Jul 28, 2024
mvertes added a commit to mvertes/yaegi that referenced this issue Jul 29, 2024
When parsing binary operator expressions, make sure that implicit
type conversions for untyped expressions are performed. It involves
walking the sub-expression subtree at post-processing of binary
expressions.

Fixes traefik#1653.
Bai-Yingjie pushed a commit to godevsig/yaegi that referenced this issue Oct 9, 2024
When parsing binary operator expressions, make sure that implicit type conversions for untyped expressions are performed. It involves walking the sub-expression subtree at post-processing of binary expressions.

Fixes traefik#1653.
Bai-Yingjie pushed a commit to godevsig/yaegi that referenced this issue Oct 9, 2024
When parsing binary operator expressions, make sure that implicit type conversions for untyped expressions are performed. It involves walking the sub-expression subtree at post-processing of binary expressions.

Fixes traefik#1653.
Bai-Yingjie pushed a commit to godevsig/yaegi that referenced this issue Oct 9, 2024
When parsing binary operator expressions, make sure that implicit type conversions for untyped expressions are performed. It involves walking the sub-expression subtree at post-processing of binary expressions.

Fixes traefik#1653.
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
Development

Successfully merging a pull request may close this issue.

2 participants