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

Variable inferred as Core.Box due to read-only access after definition #15938

Closed
nalimilan opened this issue Apr 19, 2016 · 3 comments
Closed

Comments

@nalimilan
Copy link
Member

nalimilan commented Apr 19, 2016

With latest git master, in the function below, the type of len is inferred correctly, but not lev is marked as Core.Box. Removing the ntuple call fixes this. In 0.4, the types of both variables are inferred correctly.

Feel free to close if Core.Box isn't actually an indication of type instability (I'm merely trusting @code_warntype here).

function f{N}(x::NTuple{N})
    lev = [length(y) for y in x]
    len = [length(y) for y in x]

    ntuple(i -> length(lev[i]), N)
end

@code_warntype f((1,2))
@yuyichao
Copy link
Contributor

Dup of #15276

@nalimilan
Copy link
Member Author

Ah, I had only looked for Core.Box, but the name wasn't fully qualified a few weeks ago. At least, this issue will help people doing a simple search as I did.

@yuyichao
Copy link
Contributor

To be fair, Box isn't very searchable either.... I can only find it quickly because I pasted it to a more searchable and more recent issue lately....

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