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

if func g calls f, and f is re-defined, g must use the new not the old version of f. #1673

Open
glycerine opened this issue Dec 12, 2024 · 0 comments

Comments

@glycerine
Copy link

glycerine commented Dec 12, 2024

The following program sample.go triggers an unexpected result

Basic correctness for an interpreter must allow 
func to be re-defined. All calls to the func must 
use the latest version.

On go1.23.3 darwin/amd64
yaegi v0.16.1

~~~
$ go install github.com/traefik/yaegi/cmd/yaegi@latest
go: downloading github.com/traefik/yaegi v0.16.1
$ yaegi
> func f(a, b int) int { return a + b } // start with addition
: 0xc00012f920
> f(2,3)
: 5
> func g() int { return f(2,3) }
: 0xc00068fa50
> g()
: 5
> func f(a, b int) int { return a * b } // <<- new! multiplication!
: 0xc000034c00
> g()
: 5
> 
~~~

Expected result

2 * 3 is 6, not 5. The func g is still calling the stale definition of func f.

Got

See above.

Yaegi Version

v0.16.1

Additional Notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant