-
-
Couldn't load subscription status.
- Fork 5.7k
Closed
Labels
error messagesBetter, more actionable error messagesBetter, more actionable error messagestypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
Not sure if that's the intended behaviour or not, but seems surprising:
julia> struct A{T}
x::Vector{<:T}
end
# ok:
julia> A([1, 2, 3])
A{Int64}([1, 2, 3])
# fails:
julia> A(Any[1, 2, 3])
ERROR: UndefVarError: T not defined
In my particular case, this code was a mistake anyway: I intended to write
struct A{T<:SomeSuperT}
x::Vector{T}
end
instead. But maybe it is relevant in the wider context.
I'm using the latest julia release:
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) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Metadata
Metadata
Assignees
Labels
error messagesBetter, more actionable error messagesBetter, more actionable error messagestypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch