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

Bad warnings when shadowing _ (0.6) #20931

Closed
cstjean opened this issue Mar 7, 2017 · 7 comments
Closed

Bad warnings when shadowing _ (0.6) #20931

cstjean opened this issue Mar 7, 2017 · 7 comments
Assignees
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) deprecation This change introduces or involves a deprecation
Milestone

Comments

@cstjean
Copy link
Contributor

cstjean commented Mar 7, 2017

The warnings appear only inside closures.

julia> for _ in 1:10
           function f(x)
               _ = 10
           end
       end

WARNING: deprecated syntax "_ as an rvalue".

WARNING: deprecated syntax "_ as an rvalue".
@vtjnash vtjnash added the parser Language parsing and surface syntax label Mar 7, 2017
@vtjnash vtjnash added this to the 0.6.0 milestone Mar 7, 2017
@StefanKarpinski
Copy link
Member

Resolved: we're probably not going to be able to fix this in 0.6 but we can add a line number and just tell people to use a different name in these cases.

@StefanKarpinski StefanKarpinski modified the milestones: 0.6.x, 0.6.0 Apr 6, 2017
@StefanKarpinski
Copy link
Member

Leaving it on 0.6 until the line number is printed.

@StefanKarpinski
Copy link
Member

Note that this won't be a problem on 1.0 when the deprecation goes away, so it's unclear that a fix beyond reporting a line number is necessary.

@cstjean
Copy link
Contributor Author

cstjean commented Apr 6, 2017

It causes typing issues. In the function below, _ is boxed, allocates 1.5KB for n=100, and takes 10X longer than the same code with one of the _ replaced with i.

function foo(n)
    s = 0.0
    for _ in 1:n
        function f(x)
            _ = "hey"
        end
        s += 1.0
    end
    return s
end

I know that's true for any variable name, but _ might easily be used multiple times in a function, since its value is supposedly discarded. Maybe that's a separate issue?

@yuyichao
Copy link
Contributor

yuyichao commented Apr 6, 2017

Their values are not yet discarded.

@JeffBezanson JeffBezanson self-assigned this Apr 6, 2017
@JeffBezanson JeffBezanson added deprecation This change introduces or involves a deprecation compiler:lowering Syntax lowering (compiler front end, 2nd stage) and removed parser Language parsing and surface syntax labels Apr 6, 2017
@JeffBezanson
Copy link
Member

#21301

@JeffBezanson JeffBezanson modified the milestones: 0.6.x, 0.6.0 Apr 6, 2017
@StefanKarpinski
Copy link
Member

This may get fixed in the 0.6.x time frame, but since it will go away in 1.0 when this deprecation is removed, it's a fairly low priority. Sorry for the annoyance here, but it's fairly hard to fix and since it's a temporary problem, the effort is a bit hard to justify.

JeffBezanson added a commit that referenced this issue Aug 2, 2018
JeffBezanson added a commit that referenced this issue Aug 2, 2018
closes #9343
fixes #20931

apply nospecialize to unused/underscore arguments
JeffBezanson added a commit that referenced this issue Aug 3, 2018
alyst pushed a commit to alyst/julia that referenced this issue Aug 9, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
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) deprecation This change introduces or involves a deprecation
Projects
None yet
Development

No branches or pull requests

5 participants