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

Potential lowering bug on 1.12 #55888

Closed
Drvi opened this issue Sep 26, 2024 · 4 comments
Closed

Potential lowering bug on 1.12 #55888

Drvi opened this issue Sep 26, 2024 · 4 comments
Milestone

Comments

@Drvi
Copy link
Contributor

Drvi commented Sep 26, 2024

As spotted by @NHDaly on RelationalAI slack; I'm making this issue so it doesn't get lost.

function assign_node_ids(node, starting_id::Int)

    ii = starting_id

    function _traverse::BackIRType)
        new_φ = _copy_and_assign_id(φ, ii)
        if new_φ !== φ
            ii += 1
        end
        return new_φ
    end

    _traverse(n) = n

    return (bottomup(_traverse)(node), ii)
end

Which gave

        UndefVarError: `ii` not defined in local scope
        Suggestion: check for an assignment to a local variable that shadows a global of the same name.

pointing to the first line in the closure:

        new_φ = _copy_and_assign_id(φ, ii)

CC: @gbaraldi

@NHDaly
Copy link
Member

NHDaly commented Oct 5, 2024

Thanks Tomas. @gbaraldi you have access to our codebase and this should be easy to reproduce if you want to! We can even walk you through it again on zoom if you want

@KristofferC KristofferC added this to the 1.12 milestone Feb 20, 2025
@KristofferC
Copy link
Member

KristofferC commented Feb 20, 2025

I tried the following (just naively define the undefined types and functions):

g(a,b) = b
bottomup(x) = x
struct BackIRType end

function assign_node_ids(node, starting_id::Int)
    ii = starting_id
    function _traverse::BackIRType)
        new_φ = g(φ, ii)
        if new_φ !== φ
            ii += 1
        end
        return new_φ
    end

    _traverse(n) = n

    return bottomup(_traverse)(node), ii
end

assign_node_ids(BackIRType(), 1)

and it doesn't reproduce on 1.12-nightly.

julia> assign_node_ids(BackIRType(), 1)
(1, 2)

So either this has been fixed or there is something special about the actual types and functions used in the original example (which is a bit surprising since they shouldn't affect things like what variables are defined).

@nickrobinson251
Copy link
Contributor

#57141

@nickrobinson251
Copy link
Contributor

fixed by #57201

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

4 participants