# Array(Int32) is not considered Enumerable(Int32)

**URL:** <https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458>\
**Category:** Help & Support\
**Created:** [July 2, 2021, 6:45pm UTC](https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458 "2021-07-02T18:45:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/chriscz/32/1331_2.png) [@chriscz](https://forum.crystal-lang.org/u/chriscz)\
**Post date:** [July 2, 2021, 6:45pm UTC](https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458/1 "2021-07-02T18:45:41Z")

</div>

Hi there I hope someone can help explain this to me. I’ve searched for the error in the forum and on github but I’m struggling to find an explanation. As far as I can tell it seems to be a bug in the compiler because arrays are enumerable in my experiments with simple functions. Compiling the below code on crystal v1.0.0 results in a error:

```auto
22 | @processor.call(@default, values)
                                ^-----
Error: type must be Enumerable(Int32), not Array(Int32)

```

```auto
class A(T)
  @processor : (T, Enumerable(T)) -> T

  def self.first
    ->(default : T, list : Enumerable(T)) {
      list.first || default
    }
  end

  def initialize(@default : T, @processor = self.class.first())
  end

  def call(values : Array(T))
    @processor.call(@default, values)
  end
end

A(Int32).new(0).call([1,2,3])

```

I’m still learning crystal and haven’t read all of the handbook so any help would be great!

---

<div class="post-metadata">

**Author:** ![chriscz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/chriscz/32/1331_2.png) [@chriscz](https://forum.crystal-lang.org/u/chriscz)\
**Post date:** [July 2, 2021, 7:08pm UTC](https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458/2 "2021-07-02T19:08:38Z")

</div>

Ah looks like I was able to solve it using `as`:

```auto
@processor.call(@default, values.as(Enumerable(T)))

```

But I’m still curious as to why the compiler fails

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [July 2, 2021, 9:03pm UTC](https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458/3 "2021-07-02T21:03:10Z")

</div>

This surely looks unexpected to me. Reduced reproduction:

```auto
->(list : Enumerable(Int32)){}.call([1])

```

Or, generalized:

```auto
module Foo(T)
end

class Bar(T)
  include Foo(T)
end

->(list : Foo(Int32)){}.call(Bar(Int32).new) # Error: type must be Foo(Int32), not Bar(Int32)

```

It works with class inheritance, though:

```auto
class Foo(T)
end

class Bar(T) < Foo(T)
end

->(list : Foo(Int32)){}.call(Bar(Int32).new)

```

---

<div class="post-metadata">

**Author:** ![HertzDevil](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hertzdevil/32/1023_2.png) [@HertzDevil](https://forum.crystal-lang.org/u/HertzDevil)\
**Post date:** [July 7, 2021, 2:40pm UTC](https://forum.crystal-lang.org/t/array-int32-is-not-considered-enumerable-int32/3458/4 "2021-07-07T14:40:29Z")

</div>

This is fixed on master by [Replace Crystal::Type#covariant? with #implements? by HertzDevil · Pull Request #10507 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/pull/10507).
