Commit
T{...}
replaces #12805 - add error for Tuple{x} where x isn't a Type - add error for invalid Tuple and Union types constructed via a parameterized typealias - improve error messages
- Loading branch information
There are no files selected for viewing
9 comments
on commit 85f4597
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add error for Tuple{x} where x isn't a Type
I guess you mean Type{x}
? (doesn't matter much either way...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No; general types allow non-type parameters like T{1}
, but tuples shouldn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks my code and I'm not sure how to fix it:
abstract FixedArray{T, NDim, SIZE}
typealias FixedMatrix{Row, Column, T} FixedArray{T, 2, Tuple{Row, Column}}
immutable Mat{Row, Column, T} <: FixedMatrix{Row, Column, T}
_::NTuple{Column, NTuple{Row, T}}
end
Mat(((1,2,3),)) # ERROR: TypeError: Tuple: in parameter, expected Type{T}, got Int64
abstract FixedArray{T, NDim, SIZE}
typealias FixedMatrix{Row, Column, T} FixedArray{T, 2, (Row, Column)}
ERROR: TypeError: FixedArray: in parameter, expected Type{T}, got Tuple{TypeVar,TypeVar}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really allow Tuple{1, 2}
?
Only solution I can think of so far is to use (Row, Col)
to represent the size of both FixedArray
and FixedMatrix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well as I point out it does not work for the typealias, which is pretty substantial to do all kind of things...Also it fails for TypeVar, which makes these kind of things impossible:
row{R, T}(a::Mat{R, 1, T}, j::Int) = (a.(1)[1][j],)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work:
abstract D{x, rest}
abstract Nil
typealias FixedMatrix{Row, Column, T} FixedArray{T, 2, D{Row, D{Column, Nil}}}
Maybe I should allow Tuple{2}
again to minimize breakage. I'm not sure it's a good idea though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems verbose and makes it hard to work with arbitrary dimensioned arrays. Is it that bad to have Tuple{2}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok in 877b088 I have rolled back the most breaking part of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you!
the
jl_long_type
here is a bit odd, since this doesn't really correspond tovalid_type_param