Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
blog gist
foo = begin
1
rescue
"hello"
end
# TODO: generalize this s.t.
# the problem with defer# red inference
# # assuming expression == true is dealt with
@expression = expression if @expression == nil
expression = @expression
# lib/mirah/ast/flow.rb Mirah::AST::If#infer
if expression
# ...
if then_type.compatible?(else_type)
# types are compatible...if condition is resolved, we're done
@inferred_type = then_type.narrow(else_type)
resolved! if condition_type
else
raise Mirah::Typer::InferenceError.new(
"if statement with incompatible result types #{then_type} and #{else_type}")
end
# ...
else
@inferred_type = typer.no_type
resolved!
end
foo = 1
begin
foo +=1 # result type int
rescue
puts "cant add ????" # result type void
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment