-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Description
If this is not a misinterpretation on my side, I find the following a bit shocking:
julia> macro test1()
return quote
function foo(::Type{T}=Float64) where {T}
return Vector{T}(undef, 10)
end
end
end
@test1 (macro with 1 method)
julia> @test1()
ERROR: syntax: malformed expression
Stacktrace:
[1] top-level scope
@ REPL[3]:1
julia> function foo(::Type{T}=Float64) where {T}
return Vector{T}(undef, 10)
end
foo (generic function with 2 methods)
julia> foo()
10-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Over on Zulip, someone suggested to uncomment some debug printing in jlfrontend.scm
-- the top of the Lisp stack trace you get is (for a different example macro with variable TV
, though):
(type-error car cons ())
unexpected error: #0 (caddr (:: (curly Type TV)))
#1 (resolve-expansion-vars-
(kw (:: (curly Type TV)) (curly Vector Float64))
((n . |#118#n|) (|#unused#| . |#119##unused#|) (TV . |#120#TV|))
#<julia: DynamicPPL> () #t)
But I'm unable to interpret that. (Here's the full example, run on the phg/unescape branch of Turing.jl.)
Metadata
Metadata
Assignees
Labels
No labels