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

true === nothing when expanding macro. #29836

Closed
thautwarm opened this issue Oct 29, 2018 · 2 comments · Fixed by #29838
Closed

true === nothing when expanding macro. #29836

thautwarm opened this issue Oct 29, 2018 · 2 comments · Fixed by #29838
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference

Comments

@thautwarm
Copy link
Member

This was detected when I tried to test my project MLStyle with JuliaPro 1.0.1.1 on Windows 10(64 bit), and a very ridiculous bug showed up at that time.
After that I made efforts to reproduce it without codes that depends MLStyle .
I simplify it to quite a simple case:

A = 1
B = 2

code = """
begin
    begin
        let test = x
            begin
                begin
                    let test = let
                                begin
                                    if test == 1
                                        begin
                                            println("shouldn't be nothing!")
                                            y !== 1
                                        end
                                    else
                                        nothing
                                    end
                                end
                            end

                        println("test = ", test, " => ", " `test === nothing` = ", test === nothing)
                        # true, true !!!!!!
                        if test === nothing
                            begin
                                @error "unexpected"
                            end
                        else
                            test
                        end
                    end
                end
            end
        end
    end
end
"""
ast = Meta.parse(code)

macro apply(ast)
     ast = eval(ast)
     esc(:($ast))
end

function g()
    x = 1
    y = 2
    @apply ast
end
g()

output log:

julia> include("temp/b.jl")
shouldn't be nothing!
test = true =>  `test === nothing` = true
┌ Error: unexpected
└ @ Main none:23

P.S: Only when it's inside a function, true === nothing error occurs in macro expanding, and no macro expanding works well, too.

@KristofferC
Copy link
Member

FWIW, seems a bit similar to #29253 but that was only on master I think.

@vtjnash vtjnash added compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros bug Indicates an unexpected problem or unintended behavior compiler:inference Type inference and removed compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros labels Oct 29, 2018
@vtjnash vtjnash self-assigned this Oct 29, 2018
vtjnash added a commit that referenced this issue Oct 29, 2018
Oops.

fixes #29836, and adds explicit test coverage
KristofferC pushed a commit that referenced this issue Oct 31, 2018
Oops.

fixes #29836, and adds explicit test coverage

(cherry picked from commit e270fbb)
Keno pushed a commit that referenced this issue Oct 31, 2018
Oops.

fixes #29836, and adds explicit test coverage
@KristofferC
Copy link
Member

Good MWE makes for fast fixes :)

KristofferC pushed a commit that referenced this issue Oct 31, 2018
Oops.

fixes #29836, and adds explicit test coverage

(cherry picked from commit e270fbb)
KristofferC pushed a commit that referenced this issue Nov 2, 2018
Oops.

fixes #29836, and adds explicit test coverage

(cherry picked from commit e270fbb)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Oops.

fixes #29836, and adds explicit test coverage

(cherry picked from commit e270fbb)
KristofferC pushed a commit that referenced this issue Feb 20, 2020
Oops.

fixes #29836, and adds explicit test coverage

(cherry picked from commit e270fbb)
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 compiler:inference Type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants