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

run: runtime error: invalid memory address or nil pointer dereference #1466

Closed
michaelboke opened this issue Sep 30, 2022 · 0 comments · Fixed by #1474
Closed

run: runtime error: invalid memory address or nil pointer dereference #1466

michaelboke opened this issue Sep 30, 2022 · 0 comments · Fixed by #1474
Labels
area/core bug Something isn't working

Comments

@michaelboke
Copy link

The following program sample.go triggers an unexpected result

package main

import (
	"fmt"
)

func SomeFunc(defaultValue interface{}) interface{} {
	switch v := defaultValue.(type) {
	case string:
		return v + " abc"
	case int:
		return v - 234
	}
	panic("whoops")
}

func main() {
	fmt.Println(SomeFunc("test"))
	fmt.Println(SomeFunc(1234))
}

Expected result

go run main.go
test abc
1000

Got

yaegi main.go
main.go:8:2: panic
main.go:18:2: panic
run: runtime error: invalid memory address or nil pointer dereference

Yaegi Version

0.14.2

Additional Notes

panics when appending the string

return v + " abc"
@mvertes mvertes added bug Something isn't working area/core labels Oct 3, 2022
mvertes added a commit to mvertes/yaegi that referenced this issue Oct 13, 2022
In case of interface values, make sure that the concrete type is
preserved during type inference.

Fixes traefik#1466.
traefiker pushed a commit to mvertes/yaegi that referenced this issue Oct 25, 2022
In case of interface values, make sure that the concrete type is
preserved during type inference.

Fixes traefik#1466.
traefiker pushed a commit that referenced this issue Oct 25, 2022
In case of interface values, make sure that the concrete type is preserved during type inference.

Fixes #1466.
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