Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics inheritance problem #3805

Closed
firejox opened this issue Dec 30, 2016 · 0 comments
Closed

Generics inheritance problem #3805

firejox opened this issue Dec 30, 2016 · 0 comments

Comments

@firejox
Copy link
Contributor

firejox commented Dec 30, 2016

I think this code should work or not work with meaningful error message

class Foo(T)
end

class Bar(T) < Foo(T)
end

Deque(Foo(Int32)).new.push(Bar(Int32).new)

however, compiler gave this

Error in line 7: instantiating 'Deque(Foo(Int32))#push(Bar(Int32))'

in /usr/lib/crystal/deque.cr:401: instantiating 'increase_capacity()'

    increase_capacity if @size >= @capacity
    ^~~~~~~~~~~~~~~~~

in /usr/lib/crystal/deque.cr:527: instance variable '@buffer' of Deque(Foo(Int32)) must be Pointer(Foo(Int32)), not Pointer(Foo(Int32))

      @buffer = Pointer(T).malloc(@capacity)
      ^~~~~~~

be Pointer(Foo(Int32)), not Pointer(Foo(Int32)) is not really meaningful.

Crystal version

https://carc.in#/r/1ic3
Crystal 0.20.3+2 [929a551]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants