Crystal: cast from Nil to Crystal::GenericInstanceType+ failed

Created on 22 Jun 2017  路  4Comments  路  Source: crystal-lang/crystal

From #4602

Related #4460

class HastTbl(K, V)
  @entries : EntriesArray(K, V) = EntriesArray(K, V).new

  struct EntriesArray(K, V)
    abstract struct Entry(K, V);end

    struct EntryC < Entry(K, V)
      @k : K ; @v : V
    end

    alias Chunk = Pointer(EntryC)
    alias Chunks = Pointer(Chunk)
    alias Arr = Chunks | Chunk

    @arr : Arr
    def initialize
      @arr = Chunk.new(0)
      pp typeof(@arr) #=> Arr
    end
  end
end

HastTbl(Int32, Int32).new
cast from Nil to Crystal::GenericInstanceType+ failed, at /build/crystal/src/crystal-0.22.0/src/compiler/crystal/types.cr:1361
0x432d4e: ??? at ??
0x11dd16f: ??? at ??
0x11dd183: ??? at ??
0x11d9826: ??? at ??
0x119ef75: ??? at ??
0x1068431: ??? at ??
0x106504b: ??? at ??
0x1b92f53: ??? at ??
0x47589e: ??? at ??
0x43c7ed: main at ??
0x7fbb17191511: __libc_start_main at ??
0x4097da: _start at ??
0x0: ??? at ??
Error: you've found a bug in the Crystal compiler.
Please open an issue, including source code that will allow us to reproduce the bug: 
https://github.com/crystal-lang/crystal/issues
bug compiler

All 4 comments

Reduced test case:

class X(T)
  abstract class A(T); end
  class B < A(T)
    @x : T
  end
end

https://carc.in/#/r/28my

Duplicate of #4460

Reopened because it seems to be a different issue than #4460

The issue seems to be that T in A(T) is found but shouldn't.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asterite picture asterite  路  70Comments

ezrast picture ezrast  路  84Comments

sergey-kucher picture sergey-kucher  路  66Comments

MakeNowJust picture MakeNowJust  路  64Comments

malte-v picture malte-v  路  77Comments