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

Function evaluation returns value of future definition #33342

Closed
caprilo opened this issue Sep 20, 2019 · 1 comment
Closed

Function evaluation returns value of future definition #33342

caprilo opened this issue Sep 20, 2019 · 1 comment

Comments

@caprilo
Copy link

caprilo commented Sep 20, 2019

The return value of a function is determined by the function as defined in the last appearance in the code, instead of the value of the function as it is defined at the moment of the evaluation. Take, for instance

function f()
   g() = 1
   return g()
   g() = 2
end

When calling f() it returns 2, even if the definition of g as the constant function 2 was never reached. I would expect this code to return 1.

versioninfo()

Julia Version 1.0.1
Commit 0d71392 (2018-09-29 19:05 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

@fredrikekre
Copy link
Member

Duplicate of #15602

@fredrikekre fredrikekre marked this as a duplicate of #15602 Sep 20, 2019
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

2 participants