Last active
August 29, 2015 14:20
-
-
Save will/19c4f727845b76037fcd to your computer and use it in GitHub Desktop.
union type error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias MyType = Nil | Int32 | String | Bool | |
foo = [] of MyType | |
foo << 3 | |
p foo | |
p foo.first > 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error in ./uniontype.cr:7: undefined method '>' for Nil | |
p foo.first > 1 | |
^ | |
================================================================================ | |
Nil trace: | |
/usr/local/Cellar/crystal/0.7.1/src/array.cr:538 | |
def first | |
^~~~~ | |
/usr/local/Cellar/crystal/0.7.1/src/array.cr:539 | |
first { raise IndexOutOfBounds.new } | |
^~~~~ | |
/usr/local/Cellar/crystal/0.7.1/src/array.cr:542 | |
def first | |
^~~~~ | |
/usr/local/Cellar/crystal/0.7.1/src/array.cr:543 | |
@length == 0 ? yield : @buffer[0] | |
^ | |
/usr/local/Cellar/crystal/0.7.1/src/pointer.cr:91 | |
def [](offset) | |
^~ | |
/usr/local/Cellar/crystal/0.7.1/src/pointer.cr:92 | |
(self + offset).value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment