Skip to content

Instantly share code, notes, and snippets.

@baroquebobcat
Created October 25, 2011 13:34
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 baroquebobcat/1312734 to your computer and use it in GitHub Desktop.
Save baroquebobcat/1312734 to your computer and use it in GitHub Desktop.
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