Workaround for NoReturn type for block

Not sure if this will work for everything.
It seems that NoReturn shows up as ReturnType (generic) when the
compiler detects the block will raise.
This commit is contained in:
Michael Miller 2019-08-09 15:06:22 -06:00
parent c47b47ade9
commit 8fc3af075c

View file

@ -15,7 +15,12 @@ module Spectator
end end
def self.create(proc : -> T, label : String) forall T def self.create(proc : -> T, label : String) forall T
TestBlock(T).new(proc, label) {% if T.id == "ReturnType".id %}
wrapper = -> { proc.call; nil }
TestBlock(Nil).new(wrapper, label)
{% else %}
TestBlock(T).new(proc, label)
{% end %}
end end
# Creates the block expression with a generic label. # Creates the block expression with a generic label.
@ -25,7 +30,12 @@ module Spectator
end end
def self.create(proc : -> T) forall T def self.create(proc : -> T) forall T
TestBlock(T).new(proc) {% if T.id == "ReturnType".id %}
wrapper = -> { proc.call; nil }
TestBlock(Nil).new(wrapper)
{% else %}
TestBlock(T).new(proc)
{% end %}
end end
# Reports complete information about the expression. # Reports complete information about the expression.