# Instantiation of abstract classes should raise an error

**URL:** <https://forum.crystal-lang.org/t/instantiation-of-abstract-classes-should-raise-an-error/4549>\
**Category:** Crystal Contrib\
**Created:** [April 4, 2022, 1:20am UTC](https://forum.crystal-lang.org/t/instantiation-of-abstract-classes-should-raise-an-error/4549 "2022-04-04T01:20:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SleepingInsomniac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/sleepinginsomniac/32/1442_2.png) [@SleepingInsomniac](https://forum.crystal-lang.org/u/SleepingInsomniac)\
**Post date:** [April 4, 2022, 1:20am UTC](https://forum.crystal-lang.org/t/instantiation-of-abstract-classes-should-raise-an-error/4549/1 "2022-04-04T01:20:39Z")

</div>

I noticed that I’m able to instantiate an abstract class through indirection:

```crystal
abstract class Bar
  @value : String

  def initialize(@value)
  end

  abstract def value
end

classes = [Bar]
result = classes.first.new("blah")
puts result # => #<Bar:0x103ab3e80>

```

however `Bar.new("blah")` raises `Error: can't instantiate abstract class Bar`

Is this a known behavior? It caused me a little bit of head scratching in something I was working on until I realized that my class was abstract.

Stranger was that somewhere down the line assigning the result of the the abstract class instantiation to a instance variable crash with the message: `Program received and didn't handle signal ILL (4)`

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [April 4, 2022, 1:22am UTC](https://forum.crystal-lang.org/t/instantiation-of-abstract-classes-should-raise-an-error/4549/2 "2022-04-04T01:22:48Z")

</div>

Known issue. See [Abstract classes can be created via class type · Issue #3835 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/3835).
