lib/yoda/typing/evaluator.rb in yoda-language-server-0.4.0 vs lib/yoda/typing/evaluator.rb in yoda-language-server-0.5.0

- old
+ new

@@ -198,24 +198,23 @@ # @return [Model::Types::Base] def evaluate_method_definition(node) new_caller_object = context.lexical_scope.namespace method_object = Store::Query::FindSignature.new(context.registry).select(new_caller_object, node.children[-3].to_s).first new_context = context.derive(caller_object: new_caller_object) - new_context.env.bind_method_parameters(method_object) - self.class.new(new_context).process(node.children[-1]) + new_context.env.bind_method_parameters(method_object) if method_object + method_body_node = node.children[-1] + method_body_node ? self.class.new(new_context).process(method_body_node) : nil_type end # @param node [::AST::Node] # @return [Model::Types::Base] def evaluate_smethod_definition(node) type = process(node.children[-4]) new_caller_object = type.resolve(context.registry).first method_object = Store::Query::FindSignature.new(context.registry).select(new_caller_object, node.children[-3].to_s).first new_context = context.derive(caller_object: new_caller_object) - if method_object - new_context.env.bind_method_parameters(method_object) - end + new_context.env.bind_method_parameters(method_object) if method_object self.class.new(new_context).process(node.children[-1]) end # @param object [Store::Objects::Base] # @return [Model::Types::Base] @@ -234,9 +233,13 @@ Model::Types::UnionType.new(Model::Types::ValueType.new('true'), Model::Types::ValueType.new('false')) end def unknown_type Model::Types::UnknownType.new + end + + def nil_type + Model::Types::ValueType.new('nil') end # @return [Environment] def env context.env