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

Scope bug with generator/comprehension/lambda inside of a function #26037

Closed
yurivish opened this issue Feb 13, 2018 · 2 comments
Closed

Scope bug with generator/comprehension/lambda inside of a function #26037

yurivish opened this issue Feb 13, 2018 · 2 comments
Assignees
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior needs tests Unit tests are required for this change

Comments

@yurivish
Copy link
Contributor

x() = 10

function test_passes()
   x()
   for x in 1:3
       x += x
   end
end

function test_fails()
    [x() for _ in 1:3]
    for x in 1:3
       x += x
    end
end

test_passes()
test_fails() # ERROR: LoadError: UndefVarError: x not defined

The same thing happens if you replace the comprehension with a generator or even with () -> x(), but not with a for loop.

julia> versioninfo()
Julia Version 0.7.0-DEV.3704
Commit f37d8d7a60 (2018-02-03 03:17 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin16.7.0)
  CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
Environment:
  JULIA_EDITOR = subl
@JeffBezanson JeffBezanson self-assigned this Feb 13, 2018
@JeffBezanson JeffBezanson added kind:bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage) labels Feb 13, 2018
@JeffBezanson JeffBezanson added this to the 1.0.x milestone Apr 17, 2018
@JeffBezanson
Copy link
Sponsor Member

This seems to work now that the for loop scope deprecation has been removed. Are you still able to trigger it somehow?

@JeffBezanson JeffBezanson added the needs tests Unit tests are required for this change label Sep 11, 2018
@yurivish
Copy link
Contributor Author

Nope, seems to work for me too on 1.0. 😄

JeffBezanson added a commit that referenced this issue Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) kind:bug Indicates an unexpected problem or unintended behavior needs tests Unit tests are required for this change
Projects
None yet
Development

No branches or pull requests

2 participants