Search code examples
crystal-lang

Crystal: Class+ is not a class, it's a Class+


While experimenting with the online crystal compiler (which is awesome), I've run into an error which I can't seem to find an explanation for:

class Person
  class Current < self
  end

  class Destroyed < self
  end  
end

Error: Person+ is not a class, it's a Person+

If I change the code to

class Person
  class Current < Person
  end

  class Destroyed < Person
  end  
end

Then everything works fine.

If I just do

class Person
  class Current < self
  end      
end

Then everything works fine.

Questions

  1. What is a Class+ ( / Person+... I'm assuming Person is a class)
  2. It appears that being inherited is mutating the Person class in some way. What's going on here?

Solution

  • As @RX14 stated in a comment, turns out this is a bug. Issue opened here: https://github.com/crystal-lang/crystal/issues/5495