class TypedRb::Model::TmTry
Public Class Methods
new(try_term, rescue_terms, node)
click to toggle source
Calls superclass method
TypedRb::Model::Expr::new
# File lib/typed/model/tm_try.rb, line 6 def initialize(try_term, rescue_terms, node) super(node) @try_term = try_term @rescue_terms = rescue_terms end
Public Instance Methods
check_type(context)
click to toggle source
# File lib/typed/model/tm_try.rb, line 12 def check_type(context) try_term_type = @try_term.check_type(context) rescue_term_types = @rescue_terms.map do |term| term.check_type(context) end.reject do |type| type.is_a?(Types::TyUnit) end incompatible_type = rescue_term_types.detect { |term_type| !try_term_type.compatible?(term_type) } if incompatible_type fail TypeCheckError.new("Type error checking try statement: Error in rescue clause, expected type #{try_term_type} got #{incompatible_type}", node) else try_term_type end end