-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)
Description
When an UnionAll type with a nonunique name is specified, a syntax error "invalid type parameter name "SSAValue"" is raised.
MWE (error): Foo{T<:Integer, U<:AbstractArray{T} where T<:Integer}
julia> struct Foo{T<:Integer, U<:AbstractArray{T} where T<:Integer}
a::T
b::U
end
ERROR: syntax: invalid type parameter name "SSAValue(404)" around REPL[21]:2
Stacktrace:
[1] top-level scope
@ REPL[21]:1
[2] top-level scope
@ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1428
When it is a simple type, the nested type T
is identified as the first one T<:Integer
.
Without UnionAll (no error): Bar{T<:Integer, U<:AbstractArray{T}}
julia> struct Bar{T<:Integer, U<:AbstractArray{T}}
a::T
b::U
end
julia> Bar(1, [1])
Bar{Int64, Vector{Int64}}(1, [1])
julia> Bar(1, [Int32(1])
ERROR: MethodError: no method matching Bar(::Int64, ::Vector{Int32})
Closest candidates are:
Bar(::T, ::U) where {T<:Integer, U<:(AbstractArray{T})}
@ Main REPL[45]:2
Stacktrace:
[1] top-level scope
@ REPL[64]:1
[2] top-level scope
@ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1428
With a simple UnionAll type, everything works as expected
Without conflicting name (no error): FooBar{U<:AbstractArray{T} where T<:Integer}
struct FooBar{U<:AbstractArray{T} where T<:Integer}
b::U
end
julia> FooBar([1])
FooBar{Vector{Int64}}([1])
julia> FooBar([Int32(1)])
FooBar{Vector{Int32}}(Int32[1])
Below are existing errors for different, but similar situations
function static parameter name not unique: struct BarFoo{T<:Integer, T<:AbstractFloat}
julia> struct BarFoo{T<:Integer, T<:AbstractFloat}
a::T
end
ERROR: syntax: function static parameter name not unique: "T" around REPL[22]:2
Stacktrace:
[1] top-level scope
@ REPL[22]:1
[2] top-level scope
@ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1428
function argument and static parameter name not distinct: foo(A::A) where A<:Integer = A()
julia> foo(A::A) where A<:Integer = A()
ERROR: syntax: function argument and static parameter name not distinct: "A" around REPL[13]:1
Stacktrace:
[1] top-level scope
@ REPL[13]:1
[2] top-level scope
@ ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1428
versioninfo
julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Thanks!
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)