-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Staged (@generated) functions expand macros w.r.t. incorrect world #61482
Copy link
Copy link
Open
Labels
correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwing
Description
julia> module Generated
macro bar()
return :(1)
end
@generated function foo(x::T) where T
return :(println("@bar: ", @bar, " (", $T, ")"))
end
foo(1)
macro bar()
return :(2)
end
foo(1)
foo(1.0)
end
@bar: 1 (Int64)
@bar: 1 (Int64)
@bar: 2 (Float64)The @bar macro should have been expanded in the definition world of foo, but it is instead expanded in the latest world at compilation time.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwing