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

Inconsistency of parsing results of function expression with return type #19351

Closed
colinfang opened this issue Nov 17, 2016 · 1 comment
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax

Comments

@colinfang
Copy link
Contributor

colinfang commented Nov 17, 2016

I noticed this when looking into #19122
Should we try to make them consistent so that the macro writer can have an easier life?

show(:(t(abc) = 3).args[2])

quote  # In[71], line 1:
    3
end


show(:(t(abc)::Int = 3).args[2])

3

This affects @inline, @noinline, etc.
They rely on pushmeta! which expects an Expr instead of Number for the function body.

function pushmeta!(ex::Expr, sym::Symbol, args::Any...)
    if isempty(args)
        tag = sym
    else
        tag = Expr(sym, args...)
    end

    inner = ex
    while inner.head == :macrocall
        inner = inner.args[end]::Expr
    end

    idx, exargs = findmeta(inner)
    if idx != 0
        push!(exargs[idx].args, tag)
    else
        body::Expr = inner.args[2]
        unshift!(body.args, Expr(:meta, tag))
    end
    ex
end
@kshyatt kshyatt added the parser Language parsing and surface syntax label Nov 17, 2016
@ararslan
Copy link
Member

Related to #19106?

@JeffBezanson JeffBezanson self-assigned this Jun 1, 2017
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Jun 1, 2017
JeffBezanson added a commit that referenced this issue Jun 1, 2017
tkelman pushed a commit that referenced this issue Jun 3, 2017
fixes #22135, fixes #22122, fixes #22026, fixes #21581, fixes #16096, fixes #19351

(cherry picked from commit 60675d2)
ref #22166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

4 participants