8000 Fix crash during strict typechecking by apiology · Pull Request #766 · castwide/solargraph · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix crash during strict typechecking #766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

apiology
Copy link
Contributor
@apiology apiology commented Mar 1, 2025

Nil is dereferenced when typechecking this line in the Solargraph codebase at the :strict level:

loader.add library: library, version: nil

A function is looking at the wrong signature while analyzing code, leading to the arguments being passed to the typechecking function not being consistent.

Exception:

/Users/broz/src/solargraph/lib/solargraph/type_checker.rb:368:in `kwarg_problems_for': undefined method `name' for nil:NilClass (NoMethodError)
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:332:in `block (2 levels) in argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `each_with_index'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `block in argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:314:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:314:in `argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:278:in `block in call_problems'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:251:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:251:in `call_problems'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:47:in `problems'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:155:in `block in typecheck'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:153:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:153:in `typecheck'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
	from /Users/broz/src/solargraph/bin/solargraph:5:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/bin/solargraph:25:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/bin/solargraph:25:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:451:in `exec'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:28:in `start'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/exe/bundle:28:in `block in <top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/exe/bundle:20:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/bin/bundle:25:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/bin/bundle:25:in `<main>'

Nil is dereferenced when typechecking this line in the Solargraph
codebase at the :strict level:

```
loader.add library: library, version: nil
```

A function is looking at the wrong signature while analyzing code,
leading to the arguments being passed to the typechecking function not
being consistent.

Exception:

```
/Users/broz/src/solargraph/lib/solargraph/type_checker.rb:368:in `kwarg_problems_for': undefined method `name' for nil:NilClass (NoMethodError)
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:332:in `block (2 levels) in argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `each_with_index'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:319:in `block in argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:314:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:314:in `argument_problems_for'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:278:in `block in call_problems'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:251:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:251:in `call_problems'
	from /Users/broz/src/solargraph/lib/solargraph/type_checker.rb:47:in `problems'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:155:in `block in typecheck'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:153:in `each'
	from /Users/broz/src/solargraph/lib/solargraph/shell.rb:153:in `typecheck'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
	from /Users/broz/src/solargraph/bin/solargraph:5:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/bin/solargraph:25:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/bin/solargraph:25:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:451:in `exec'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/cli.rb:28:in `start'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/exe/bundle:28:in `block in <top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/broz/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.5.4/exe/bundle:20:in `<top (required)>'
	from /Users/broz/.rbenv/versions/3.0.6/bin/bundle:25:in `load'
	from /Users/broz/.rbenv/versions/3.0.6/bin/bundle:25:in `<main>'
```
@castwide
Copy link
Owner
castwide commented Mar 8, 2025

👍 :shipit:

@castwide castwide merged commit 73ef94a into castwide:master Mar 8, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0