-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] "cast from Nil to Crystal::GenericInstanceType+ " #6390
Comments
Reduced: class Foo
def initialize
@x = Array.new(10) { Array.new(10, false) }
end
end
Foo.new |
Minimal code is class Foo
def initialize
@x= Array.new(1) { }
end
end
Foo.new It seems it fails due to it being an instance assign as, without it, it compiles as normal. If N was still there, it would compile complaining about not inferring N. E: Astersniped |
Reduced with class Gen(T)
def self.new(&block)
Gen(T).build
end
def self.build : self
end
end
class Foo
def initialize
@x = Gen.new { }
end
end
Foo.new You can workaround it by manually specifying the type of the instance variables: class P082
@visited : Array(Array(...))
# etc.
end |
I think it's a slightly different scenario. In any case you'll need to write those type declarations even after the bug is fixed. Out of curiosity, what are the other 81 problems? :-) |
This comment specifically is the reduction that fails in this issue. #5383 (comment) |
I'm uploading them soon 😛 as starting a polyglot path and my first step is "Solve the first 100". I have done that as the work around. |
Just encountered this with the following code: class Example
def initialize(@args = ARGV)
end
end https://play.crystal-lang.org/#/r/5s9l
I think it's related to this issue because it's failing to figure out the type is class Example
def initialize(@args : Array(String) = ARGV)
end
end Not as elegant, but it works. |
Hello, I found a bug while solving this
Here are some details:
The source is:
I'm happy of helping at least with a bug reported.
If I can help don't hesitate on contact me.
Thanks guys and keep up the good job!
The text was updated successfully, but these errors were encountered: