The following works fine in 0.6:
julia> f(x) = @evalpoly x 1.0 2.0 3.0
f (generic function with 1 method)
julia> Base.Test.@inferred f(3.0)
ERROR: return type Float64 does not match inferred return type Any
Stacktrace:
[1] error(::String) at ./error.jl:28
Probably the same as JuliaMath/SpecialFunctions.jl#42, where it was bisected to #22985.
cc @vtjnash
This is basically https://github.com/JuliaLang/julia/issues/23221. Right now it's impossible to write macros that calls other macros correctly without doing everything manually.
As a workaround, we could inline the @horner macro; we could even eliminate that undocumented macro entirely in favor of @evalpoly.
However, in the long run I think we need to make it possible for macros to call macros.
From the code_lowered for f:
Base.Math.t = tt
SSAValue(0) = (Base.Math.muladd)(Base.Math.t, (Base.Math.muladd)(Base.Math.t, 3.0, 2.0), 1.0)
# meta: pop location
return SSAValue(0)
The horner macro returns a block with an assignment to a (hygienic) variable t, which somehow becomes a global. This seems different from the other recent macro issues, since t should be local no matter which scope it belongs to.
Reduced example:
julia> macro id(x)
esc(x)
end
julia> macro aa()
quote
a = 1
@id b = 1
end
end
julia> @aa;
julia> a
ERROR: UndefVarError: a not defined
julia> b
1
I can see why this happens, but I find it really confusing.
Just came across what's presumably the same bug. On 0.6:
julia> W2 = @evalpoly(0.1729150690306449, @evalpoly(1.2151064605177766, -27.0, -84.0, -56.0),
-11.614665966268532,
163.17740776843848)
-208.88143856876326
On 0.7:
julia> W2 = @evalpoly(0.1729150690306449, @evalpoly(1.2151064605177766, -27.0, -84.0, -56.0),
-11.614665966268532,
163.17740776843848)
-191.5798454805012
@dlfivefifty, your case is also fixed by #23247.
👍 FastGaussQuadrature.jl now passes all tests on 0.7