Skip to content

Instantly share code, notes, and snippets.

@taylorfinnell
Last active January 18, 2018 21:44
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 taylorfinnell/4f71199f746fe8abca9b214827ebf144 to your computer and use it in GitHub Desktop.
Save taylorfinnell/4f71199f746fe8abca9b214827ebf144 to your computer and use it in GitHub Desktop.
hello
class Test
def on_thing(&block : Int32 ->)
@on_thing_cb = block
end
end
class A
def hi
end
end
x = [A.new, nil]
test = Test.new
if y = x[0]
test.on_thing do |i|
y.hi # undefined method 'hi' for Nil (compile-time type is (A | Nil))
end
end
# If I change the last part to do this, no error
test = Test.new
if y = x[0]
g = y
test.on_thing do |i|
g.hi
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment