Skip to content

Instantly share code, notes, and snippets.

@will
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save will/19c4f727845b76037fcd to your computer and use it in GitHub Desktop.
Save will/19c4f727845b76037fcd to your computer and use it in GitHub Desktop.
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