Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected TypeError: in Vararg, in type, expected Type, got Vararg{Union{Float64, AbstractArray}} in Julia 1.9 #48950

Closed
kmeers-kuleuven opened this issue Mar 8, 2023 · 2 comments · Fixed by #48953
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version
Milestone

Comments

@kmeers-kuleuven
Copy link

One of the tests of https://gitlab.kuleuven.be/ppw-okpiv/research/GradientDiffusion.jl/ fails in Julia 1.9-beta/rc1 with ERROR: TypeError: in Vararg, in type, expected Type, got Vararg{Union{Float64, AbstractArray}}. In Julia 1.8 it works without issues.

This is a minimal working/failing example:

module j
    struct k{
        b,
        c}
        d
        function k(e::Vararg{Union{b, AbstractArray}}) where b
            c = Union
            new{b, c}(e)
        end
    end
    l(a) = getfield(a, :d)
    function a(b, c)
        c(l(b[])...)
    end
    function o(a)
        function(b, ::Vararg{Union{c, AbstractArray}}) where {c, d}
        end
    end
    function fit(z, f, d)
        b = [ k([0.], 0.) ]
        a(b, (i...) -> d(z, i...))
    end
end
c = d = []
j.fit(j, d, j.o(c))

Output in Julia 1.8:

Output in Julia 1.9:

ERROR: TypeError: in Vararg, in type, expected Type, got Vararg{Union{Float64, AbstractArray}}
Stacktrace:
 [1] (::Main.j.var"#3#4"{Module, Main.j.var"#1#2"})(::Vector{Float64}, ::Vararg{Any})
   @ Main.j .\REPL[7]:21
 [2] a
   @ .\REPL[7]:13 [inlined]
 [3] fit(z::Module, f::Vector{Any}, d::Function)
   @ Main.j .\REPL[7]:21
 [4] top-level scope
   @ REPL[9]:1

The example is reproducible in Windows and Linux.
i.e. of versioninfo():

Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc (2023-03-07 07:51 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_EDITOR = code
@N5N3 N5N3 added bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version labels Mar 8, 2023
@N5N3
Copy link
Member

N5N3 commented Mar 8, 2023

Smaller MWE

julia> function h(::Vararg{Union{c, AbstractArray}}) where {c, d}
           1
       end
WARNING: method definition for h at REPL[6]:1 declares type variable d but does not use it.
h (generic function with 1 method)

julia> h(1,1)
ERROR: TypeError: in Vararg, in type, expected Type, got Vararg{Union{Int64, AbstractArray}}
Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

@martinholters
Copy link
Member

martinholters commented Mar 8, 2023

Goes away if wrapped in another function:

julia> g(x...) = h(x...)
g (generic function with 1 method)

julia> h(1, 1)
ERROR: TypeError: in Vararg, in type, expected Type, got Vararg{Union{Int64, AbstractArray}}
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> g(1, 1)
1

EDIT: And notably, after that, also

julia> h(1, 1)
1

@KristofferC KristofferC added this to the 1.9 milestone Mar 8, 2023
vtjnash pushed a commit that referenced this issue Mar 8, 2023
KristofferC pushed a commit that referenced this issue Mar 24, 2023
Avoid possible nested `Vararg`.

Fix #48950

(cherry picked from commit 4da0359)
Xnartharax pushed a commit to Xnartharax/julia that referenced this issue Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants