代码之家  ›  专栏  ›  技术社区  ›  John

克里斯托:课堂+不是课堂,而是课堂+

  •  3
  • John  · 技术社区  · 8 年前

    在试验时 online crystal compiler (这太棒了),我遇到了一个错误,我似乎找不到解释:

    class Person
      class Current < self
      end
    
      class Destroyed < self
      end  
    end
    

    错误: Person+ is not a class, it's a Person+

    如果我将代码更改为

    class Person
      class Current < Person
      end
    
      class Destroyed < Person
      end  
    end
    

    然后一切正常。

    如果我这么做

    class Person
      class Current < self
      end      
    end
    

    然后一切正常。

    问题

    1. 什么是 Class+ ( / Person+ ... 我想 Person 是一个类)
    2. 看来 正在继承 正在变异 在某种程度上讲。这是怎么回事?
    1 回复  |  直到 8 年前
        1
  •  1
  •   John    8 年前

    正如@RX14在一条评论中所述,这是一个bug。此处打开的问题: https://github.com/crystal-lang/crystal/issues/5495