|
39 | 39 | @pure tuple_minimum(T::Tuple) = minimum(T)
|
40 | 40 |
|
41 | 41 | # Something doesn't match up type wise
|
42 |
| -function check_array_parameters(Size, T, N, L) |
43 |
| - (!isa(Size, DataType) || (Size.name !== Tuple.name)) && throw(ArgumentError("Static Array parameter Size must be a Tuple type, got $Size")) |
44 |
| - !isa(T, Type) && throw(ArgumentError("Static Array parameter T must be a type, got $T")) |
45 |
| - !isa(N.parameters[1], Int) && throw(ArgumenError("Static Array parameter N must be an integer, got $(N.parameters[1])")) |
46 |
| - !isa(L.parameters[1], Int) && throw(ArgumentError("Static Array parameter L must be an integer, got $(L.parameters[1])")) |
| 42 | +@generated function check_array_parameters(Size, T, N, L) |
| 43 | + (!isa(Size, DataType) || (Size.name !== Tuple.name)) && return :(throw(ArgumentError("Static Array parameter Size must be a Tuple type, got $Size"))) |
| 44 | + !isa(T, Type) && return :(throw(ArgumentError("Static Array parameter T must be a type, got $T"))) |
| 45 | + !isa(N.parameters[1], Int) && return :(throw(ArgumenError("Static Array parameter N must be an integer, got $(N.parameters[1])"))) |
| 46 | + !isa(L.parameters[1], Int) && return :(throw(ArgumentError("Static Array parameter L must be an integer, got $(L.parameters[1])"))) |
47 | 47 | # shouldn't reach here. Anything else should have made it to the function below
|
48 |
| - error("Internal error. Please file a bug") |
| 48 | + return :(error("Internal error. Please file a bug")) |
49 | 49 | end
|
50 | 50 |
|
51 | 51 | @generated function check_array_parameters{Size,T,N,L}(::Type{Size}, ::Type{T}, ::Type{Val{N}}, ::Type{Val{L}})
|
52 | 52 | if !all(x->isa(x, Int), Size.parameters)
|
53 |
| - throw(ArgumentError("Static Array parameter Size must be a tuple of Ints (e.g. `SArray{Tuple{3,3}}` or `SMatrix{3,3}`).")) |
| 53 | + return :(throw(ArgumentError("Static Array parameter Size must be a tuple of Ints (e.g. `SArray{Tuple{3,3}}` or `SMatrix{3,3}`)."))) |
54 | 54 | end
|
55 | 55 |
|
56 | 56 | if L != tuple_prod(Size) || L < 0 || tuple_minimum(Size) < 0 || tuple_length(Size) != N
|
57 |
| - throw(ArgumentError("Size mismatch in Static Array parameters. Got size $Size, dimension $N and length $L.")) |
| 57 | + return :(throw(ArgumentError("Size mismatch in Static Array parameters. Got size $Size, dimension $N and length $L."))) |
58 | 58 | end
|
59 | 59 |
|
60 | 60 | return nothing
|
|
0 commit comments