Created
October 25, 2011 13:34
-
-
Save baroquebobcat/1312734 to your computer and use it in GitHub Desktop.
blog gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo = begin | |
1 | |
rescue | |
"hello" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: generalize this s.t. | |
# the problem with defer# red inference | |
# # assuming expression == true is dealt with | |
@expression = expression if @expression == nil | |
expression = @expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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