diff --git a/lib/solargraph/type_checker.rb b/lib/solargraph/type_checker.rb index 059caaeff..9fbbe24d2 100644 --- a/lib/solargraph/type_checker.rb +++ b/lib/solargraph/type_checker.rb @@ -542,7 +542,7 @@ def fake_args_for(pin) def without_ignored problems problems.reject do |problem| node = source_map.source.node_at(problem.location.range.start.line, problem.location.range.start.column) - source_map.source.comments_for(node)&.include?('@sg-ignore') + node && source_map.source.comments_for(node)&.include?('@sg-ignore') end end end diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index 22bbd3631..60c8efeae 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -4,6 +4,18 @@ def type_checker(code) Solargraph::TypeChecker.load_string(code, 'test.rb', :strict) end + it 'complains on @!parse blocks too' do + checker = type_checker(%( + # @!parse + # class Foo + # # @return [Bar] + # def baz; end + # end + )) + expect(checker.problems).to be_one + expect(checker.problems.first.message).to include('Unresolved return type Bar for Foo#baz') + end + it 'ignores method calls with inferred types' do checker = type_checker(%( String.new.upcase