Skip to content

Instantly share code, notes, and snippets.

@will
Last active Aug 29, 2015
Embed
What would you like to do?
union type error
alias MyType = Nil | Int32 | String | Bool
foo = [] of MyType
foo << 3
p foo
p foo.first > 1
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