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

Conditional Definition of Functions Incorrect Answer and Error #16965

Closed
ChrisRackauckas opened this issue Jun 16, 2016 · 1 comment
Closed

Comments

@ChrisRackauckas
Copy link
Member

This is from julia-users. The example is:

function g(a)
  if a
    f() = 2
  else
    f() = 3
  end
  return f
end
f = g(true)
f() # Returns 3

What's also interesting is that g(false) in another REPL session gives an error: "f not defined". So in this setup you either get the second function (if you ask for the first one), or you get nothing! This is on Commit 59d1539 (4 days old master).

@JeffBezanson
Copy link
Sponsor Member

Duplicate of #15602

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