Multiple keyword arguments with no default -> "Call to #foo is missing keyword argument"
When I have multiple keyword arguments with no default, solargraph typecheck --level=strict gives a false positive:
broz@bigbookpro:~/src/repro-project$ cat > repro.rb
# @param i [Integer]
# @param s [Integer]
def foo(a:, b:)
end
foo(a: 123, b: 456)
broz@bigbookpro:~/src/repro-project$
solargraph typecheck --level=strict repro.rb gives the error:
/Users/broz/src/repro-project/repro.rb:7 - Call to #foo is missing keyword argument bCall to #foo is missing keyword argument b
This is surprising, as I am providing that argument:
foo(a: 123, b: 456)
Full repro session
broz@bigbookpro:~/src/repro-project$ solargraph typecheck --level=strict repro.rb [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Proc ^(K) -> V? [WARN] Unrecognized RBS type: RBS::Types::Proc ^(K) -> V? [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Intersection X & ::io [WARN] Unrecognized RBS type: RBS::Types::Intersection X & ::io [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Proc ^(untyped) -> A [WARN] Unrecognized RBS type: RBS::Types::Proc ^(::Integer id) -> void [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance /Users/broz/src/repro-project/repro.rb:7 - Call to #foo is missing keyword argument bCall to #foo is missing keyword argument b 1 problem found. broz@bigbookpro:~/src/repro-project$ solargraph typecheck repro.rb 0 problems found. broz@bigbookpro:~/src/repro-project$ solargraph --version 0.49.0 broz@bigbookpro:~/src/repro-project$
Totally still a thing. Works flawlessly, but Solargraph can't see what's clearly there.
I would love to be able to suppress only this specific error at this specific position, like Rubocop allows so that once this bug is fixed — I'm not stuck with a spot that SG is blind to.
You can use an @sg-ignore tag to suppress typechecking errors from the next line of code.
def example();end
# @sg-ignore
example(1, 2)
# solargraph typecheck will ignore the "too many arguments" error from the method call
One tiny other thing I felt compelled to mention, the @sg-ignore tag also works when you add text to explain why it's necessary:
def example();end
# @sg-ignore We need to document the magic that makes arguments work here
example(1, 2)
That's nonspecific. If I use @sg-ignore there and then this SG bug gets fixed — I will never know that it's no longer needed there. And if another kind of issue creeps into that line — I won't be getting informed of it by LSP. Accumulating indiscriminate warning suppressors in your code is not a great practice, especially as the semantic context changes with development.
I see what you're saying. Unfortunately, there's currently no way to suppress typecheck errors with that level of granularity. I'm open to suggestions for making it more robust.
What I referred to — drawing a parallel to RuboCop — was this: RuboCop Docs → Configuration → Disabling Cops within Source Code