tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

arrays get implicitely casted to pointers #97

Closed porky11 closed 7 years ago

porky11 commented 8 years ago

Another array problem,

(def main (fn extern-c void (void)
  (def x (var auto (array-of 2 int) (array 0 0)))
  (def y (var auto (array-of 2 int) x))
  (return)))
;;error: expected expression with type (array-of 2 int) (got type (p int) instead)

x has been casted to (p int) and I have to cast it back to (array-of 2 int)

tomhrr commented 8 years ago

On Tue, Sep 13, 2016 at 02:58:38PM -0700, Fabio Krapohl wrote:

Another array problem,

(def main (fn extern-c void (void) (def x (var auto (array-of 2 int) (array 0 0))) (def y (var auto (array-of 2 int) x)) (return))) ;;error: expected expression with type (array-of 2 int) (got type (p int) instead)

x has been casted to (p int) and I have to cast it back to (array-of 2 int)

Although casts to arrays were permitted, the implementation did not work properly. For uniformity with C/C++, these casts have now been removed. However, arrays can now be initialised by way of other arrays of the same size and type, so that the above works as expected.