Instantiation of abstract classes should raise an error

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

abstract class Bar
  @value : String

  def initialize(@value)

  abstract def value

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

however"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)

1 Like

Known issue. See Abstract classes can be created via class type · Issue #3835 · crystal-lang/crystal · GitHub.