-
-
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
{"a", "b"}.as Enumerable(String)
crashes the compiler
#8771
Comments
{"a", "b"}.as(Enumerable(String))
crashes the compiler{"a", "b"}.as Enumerable(String)
crashes the compiler
Not sure why the line numbers aren't showing up. Huh? On OS X:
|
These works (Crystal 0.32.1) - the problem seems to happen only when there are 2 elements - the compiler somehow assumes that one of the elements could be a Nil:
@rdp , the line numbers are not showing properly for me as well (Ubuntu 16.04, Crystal 0.33.0 [612825a] (2020-02-14)):
|
Reduced: # `Tuple` (built-in type declared by `Crystal::Program`)
struct Foo(*T)
end
# `ENV` (src/env.cr)
module Bar
extend Enumerable(Foo(String, String))
end
# `Tuple` (src/tuple.cr, this file is required after src/env.cr)
struct Foo(*T)
include Enumerable(Union(*T))
end
def foo
Foo(String, String).new.as(Enumerable(String))
{% p Enumerable(String).includers %} # => [] of ::NoReturn
end
foo
module Bar
extend Enumerable({String, String})
end
struct Tuple(*T)
include Enumerable(Union(*T))
end
class Foo2
include Enumerable(String)
end
def foo
{"a"}.as(Enumerable(String))
{"a", "b"}.as(Enumerable(String))
{% p Enumerable(String).includers %} # => [Foo2, Tuple(String)]
end
foo
Related: #10518 |
Code:
Result:
Playground link
Version:
It specifically seems to be with
Tuple(String)
when the tuple has more than one string.{1, 2}.as Enumerable(Int32)
does not crash the compiler, nor does{"a"}.as Enumerable(String)
.The text was updated successfully, but these errors were encountered: