JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.67k stars 5.48k forks source link

Confusing error when adding too many type parameters #45078

Open jakobnissen opened 2 years ago

jakobnissen commented 2 years ago

The following error message is quite confusing:

julia> BitVector{1}
ERROR: TypeError: in Type{...} expression, expected UnionAll, got Type{BitVector}
Stacktrace:
 [1] top-level scope
   @ REPL[5]:1

The problem with the code is that BitVector does not take any type parameters. In contrast, if you make the same error with BitArray, which does take type parameters, you get a much nicer error:

julia> BitArray{1,2}
ERROR: too many parameters for type
Stacktrace:
 [1] top-level scope
   @ REPL[8]:1

I think it would be nicer if:

Seelengrab commented 2 years ago

It's a bit different - BitVector{1} is actually this:

julia> BitArray{1}{1}
ERROR: TypeError: in Type{...} expression, expected UnionAll, got Type{BitVector}
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

It's just not exposed that BitVector is actually an BitArray{1} here..