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

bug Hash#fetch #67

Closed
kostya opened this issue Jan 15, 2014 · 2 comments
Closed

bug Hash#fetch #67

kostya opened this issue Jan 15, 2014 · 2 comments

Comments

@kostya
Copy link
Contributor

kostya commented Jan 15, 2014

class A
end

x = {} of Int32 => A
x.fetch(10) { A.new }

got big llvm error

Nil assertion failed:
*raise<String>:NoReturn + [53765888]
*Nil#not_nil!<Nil>:NoReturn + [53765888]
*Crystal::LLVMTyper#create_llvm_struct_type<Crystal::LLVMTyper, Crystal::NonGenericClassType+ | Crystal::Metaclass+ | Crystal::GenericClassInstanceType+ | Crystal::HierarchyType+>:Pointer(Void) + [53765888]
*Crystal::LLVMTyper#llvm_type<Crystal::LLVMTyper, Crystal::Type+>:Pointer(Void) + [53765888]
*Crystal::LLVMTyper#llvm_type<Crystal::LLVMTyper, Crystal::Type+>:Pointer(Void) + [53765888]
...
@asterite
Copy link
Member

@kostya Thanks for reporting this. It's a bug we've known for some time but we still don't know how to fix it.

The good thing is that once you insert something in your hash, the error is gone (and typically a program will insert something in the hash, otherwise... why use it?).

But we believe it's something fixable. And the good thing is now this bug is being tracked somewhere :-)

@asterite
Copy link
Member

The smallest example to reproduce it is this:

class Foo
  def initialize(@x)
  end

  def x
    @x
  end
end

p = Pointer(Foo).malloc(1)
p.value.x

Because Foo is never initialized, we never get to know the type of @x. So we can't tell LLVM what's the complete type of Foo.

We'll think of something...

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

No branches or pull requests

2 participants