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

Redeclaration scope issue #1378

Closed
cclerget opened this issue Apr 8, 2022 · 0 comments · Fixed by #1379
Closed

Redeclaration scope issue #1378

cclerget opened this issue Apr 8, 2022 · 0 comments · Fixed by #1379
Labels
area/core bug Something isn't working
Milestone

Comments

@cclerget
Copy link
Contributor

cclerget commented Apr 8, 2022

The following program sample.go triggers an unexpected result

package main

import (
	"fmt"
	"time"
)

func main() {
	t, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
	if err != nil {
		panic(err)
	}
	fn := func() error {
		_, err := t.GobEncode()
		return err
	}
	fmt.Println(fn())
}

Expected result

$ go run ./sample.go
<nil>

Got

$ yaegi ./sample.go
run: reflect: call of reflect.Value.Set on zero Value
goroutine 1 [running]:
runtime/debug.Stack()
	/usr/lib/go-1.17/src/runtime/debug/stack.go:24 +0x65
github.com/traefik/yaegi/interp.(*Interpreter).Execute.func1()
	/home/xxx/git/yaegi/interp/program.go:131 +0x94
panic({0xd18ee0, 0xc00000e7c8})
	/usr/lib/go-1.17/src/runtime/panic.go:1038 +0x215
github.com/traefik/yaegi/interp.runCfg.func1()
	/home/xxx/git/yaegi/interp/run.go:193 +0x145
panic({0xd18ee0, 0xc00000e7c8})
	/usr/lib/go-1.17/src/runtime/panic.go:1038 +0x215
github.com/traefik/yaegi/interp.runCfg.func1()
	/home/xxx/git/yaegi/interp/run.go:193 +0x145
panic({0xd18ee0, 0xc00000e7c8})
	/usr/lib/go-1.17/src/runtime/panic.go:1038 +0x215
reflect.flag.mustBeAssignableSlow(0xc0004af6c8)
	/usr/lib/go-1.17/src/reflect/value.go:255 +0x116
reflect.flag.mustBeAssignable(...)
	/usr/lib/go-1.17/src/reflect/value.go:249
reflect.Value.Set({0x0, 0x0, 0xc0004af6c8}, {0xd39d80, 0xc0000a3050, 0x416334})
	/usr/lib/go-1.17/src/reflect/value.go:1899 +0x6a
github.com/traefik/yaegi/interp.callBin.func8(0x10)
	/home/xxx/git/yaegi/interp/run.go:1628 +0x1cb
github.com/traefik/yaegi/interp.runCfg(0xc0004b4d80, 0xc0003b02c0, 0x464fe5, 0x4cf1de)
	/home/xxx/git/yaegi/interp/run.go:201 +0x2ac
github.com/traefik/yaegi/interp.call.func9(0xc0003b0160)
	/home/xxx/git/yaegi/interp/run.go:1434 +0x94e
github.com/traefik/yaegi/interp.runCfg(0xc0003bbd40, 0xc0003b0160, 0xc0003bb320, 0xc0004afa80)
	/home/xxx/git/yaegi/interp/run.go:201 +0x2ac
github.com/traefik/yaegi/interp.(*Interpreter).run(0xc0003ae000, 0xc0003bb320, 0xc0003b0000)
	/home/xxx/git/yaegi/interp/run.go:120 +0x385
github.com/traefik/yaegi/interp.(*Interpreter).Execute(0xc0003ae000, 0xc0004b9050)
	/home/xxx/git/yaegi/interp/program.go:157 +0x24b
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc0003ae000, {0xc000300480, 0x10d}, {0x7ffe5613f076, 0xc000300240}, 0xd)
	/home/xxx/git/yaegi/interp/interp.go:615 +0x5c
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc0003ae000, {0x7ffe5613f076, 0xb})
	/home/xxx/git/yaegi/interp/interp.go:508 +0xab
main.runFile(0x7ffe5613f076, {0x7ffe5613f076, 0xb}, 0x0)
	/home/xxx/git/yaegi/cmd/yaegi/run.go:153 +0x8f
main.run({0xc000130010, 0x8001, 0xc00008e6b8})
	/home/xxx/git/yaegi/cmd/yaegi/run.go:116 +0xbec
main.main()
	/home/xxx/git/yaegi/cmd/yaegi/yaegi.go:144 +0x2dd

Yaegi Version

v0.11.3

Additional Notes

Tracked to #1367

@mvertes mvertes added bug Something isn't working area/core labels Apr 9, 2022
@mvertes mvertes added this to the v0.11.x milestone Apr 9, 2022
traefiker pushed a commit that referenced this issue Apr 9, 2022
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