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

Fix introspection macros for getproperty #35895

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions stdlib/InteractiveUtils/src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ function gen_call_with_extracted_types(__module__, fcn, ex0, kws=Expr[])
fully_qualified_symbol &= ex1 isa Symbol
if fully_qualified_symbol
if string(fcn) == "which"
return quote $(fcn)($(esc(ex0.args[1])), $(ex0.args[2])) end
else
return Expr(:call, :error, "expression is not a function call or symbol")
return quote
local arg1 = $(esc(ex0.args[1]))
if isa(arg1, Module)
$(fcn)(arg1, $(ex0.args[2]))
else
local args = typesof($(map(esc, ex0.args)...))
$(fcn)(Base.getproperty, args)
end
end
end
elseif ex0.args[2] isa Expr
return Expr(:call, :error, "dot expressions are not lowered to "
Expand Down
8 changes: 7 additions & 1 deletion stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,15 @@ B33163(x) = x

# Issue #14637
@test (@which Base.Base.Base.nothing) == Core
@test_throws ErrorException (@functionloc Base.nothing)
@test (@functionloc Base.nothing)[2] isa Integer
@test (@code_typed (3//4).num)[2] == Int

struct A14637
x
end
a14637 = A14637(0)
@test (@which a14637.x).name == :getproperty

# Issue #28615
@test_throws ErrorException (@which [1, 2] .+ [3, 4])
@test (@code_typed optimize=true max.([1,7], UInt.([4])))[2] == Vector{UInt}
Expand Down