You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating an old project to the current Crystal release I found a case that used to work but now fails to build and looks like a compiler bug. Here is a reduced version:
aliasType=Array(Type) |String
arr = ["aa", ["23"]] of Typep arr # this worksp arr *2# this doesn't compile
Here is the compiler output:
In test.cr:6:7
6 | p arr * 2
^
Error: instantiating 'Array(Type)#*(Int32)'
In /usr/share/crystal/src/array.cr:337:23
337 | return Array(T).new(times, first)
^--
Error: instantiating 'Array(Type).class#new(Int32, (Array(String) | Array(Type) | String))'
In /usr/share/crystal/src/array.cr:116:7
116 | @buffer = Pointer(T).malloc(size, value)
^------
Error: instance variable '@buffer' of Array(Type) must be Pointer(Array(String) | Array(Type) | String), not Pointer(Array(String) | Array(Type) | String)
In particular, notice that the last line says Pointer(Array(String) | Array(Type) | String) is not the same as Pointer(Array(String) | Array(Type) | String). But they look pretty much the same to me. Not sure what is going on.
When updating an old project to the current Crystal release I found a case that used to work but now fails to build and looks like a compiler bug. Here is a reduced version:
Here is the compiler output:
In particular, notice that the last line says
Pointer(Array(String) | Array(Type) | String)
is not the same asPointer(Array(String) | Array(Type) | String)
. But they look pretty much the same to me. Not sure what is going on.This used to work on Crystal 0.30.1 (https://play.crystal-lang.org/#/r/88y1) but broke on Crystal 0.31.0 (https://play.crystal-lang.org/#/r/88y0)
The text was updated successfully, but these errors were encountered: