Skip to content

Providing a non-Int64 N parameter to NTuple within a struct does not throw error #47748

Closed
@mkitti

Description

@mkitti

I provide a Int8 or UInt8 value as the first parameter to a NTuple within a struct, I get a Union{} for its type with fieldtype. I would have expected an error similar to the one received when trying to construct a NTuple directly.

julia> struct S{P}
           x::NTuple{P,UInt32}
       end

julia> fieldtype(S{2},1)
Tuple{UInt32, UInt32}

julia> fieldtype(S{0x2},1)
Union{}

julia> fieldtype(S{Int8(2)},1)
Union{}

julia> fieldtype(S{Int16(2)},1)
Union{}

julia> fieldtype(S{Int32(2)},1)
Union{}

julia> fieldtype(S{Int64(2)},1)
Tuple{UInt32, UInt32}

julia> fieldtype(S{Int128(2)},1)
Union{}

julia> NTuple{0x2, UInt32}
ERROR: TypeError: in Vararg, in count, expected Int64, got a value of type UInt8
Stacktrace:
 [1] top-level scope
   @ REPL[15]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions