If you can elaborate a bit on what you’re trying to do, we may be able to provide some more useful advice. What is your macro doing that would require knowing the type of y inside the macro?
Like yuyichao said this is probably not a good idea, but just for fun and education, there’s a macro (@code_typed) that shows you the inferred types. You can find what function it’s calling by doing:
macroexpand(:(@code_typed f(2)))
Turns out it’s calling code_typed in Base:
codeinfo = Base.code_typed(f,Tuple{Int64})[1]
You can get the inferred types from the CodeInfo object, e.g.:
function f(x)
z = 3
y = 2.0x
end
codeinfo = Base.code_typed(f,Tuple{Int64})[1]
collect(zip(codeinfo.first.slotnames, codeinfo.first.slottypes))
4-element Array{Tuple{Any,Any},1}:
(Symbol("#self#"), #f)
(:x, Int64)
(:z, Int64)
(:y, Float64)