asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

Should array types allow implicit integer casts? #25

Closed asoffer closed 3 years ago

asoffer commented 3 years ago

Currently array lengths need to be integral but will be implicitly cast to the underlying array-type's length implementation type. This is currently a uint64_t so any natively supported type in Icarus can convert to this losslessly (because negative lengths are prohibited). However, if Icarus starts supporting larger integer types this cast will be lossy and implicit.

This issue tracks simply making a decision here. There is a nice consistency in always requiring the cast. There is also no reason to support arrays of length 2^64 or greater in any reasonable future.

asoffer commented 3 years ago

As discussed in #51, we will move to having a constant numeric type which implicitly converts to all others (more details in that issue). This nicely resolves this issue as well; the array length field must be a non-negative integral constant.