Julia: Cannot splat types into inner constructor

Created on 5 Oct 2020  路  1Comment  路  Source: JuliaLang/julia

I recently came across that splatting types into outer constructors works fine:

julia> struct Foo{A,B}
           a
           b
       end

julia> function Foo(a,b)
           args = (a, b)
           return Foo{typeof.(args)...}(args...)
       end
Foo

But splatting types into the inner constructor (new{}) fails:

julia> struct Foo{A,B}
           a
           b
           function Foo(a,b)
               args = (a, b)
               return new{typeof.(args)...}(args...)
           end
       end
ERROR: syntax: too few type parameters specified in "new{...}" around REPL[1]:1
Stacktrace:
 [1] top-level scope at REPL[1]:1
lowering

Most helpful comment

Ok, good news. I think we can just remove this error check.

>All comments

Ok, good news. I think we can just remove this error check.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omus picture omus  路  3Comments

yurivish picture yurivish  路  3Comments

TotalVerb picture TotalVerb  路  3Comments

manor picture manor  路  3Comments

m-j-w picture m-j-w  路  3Comments