Skip to content

Fix TypeError when resolver has no state#4

Open
khasinski wants to merge 1 commit into
socketry:mainfrom
khasinski:fix-resolver-nil-state
Open

Fix TypeError when resolver has no state#4
khasinski wants to merge 1 commit into
socketry:mainfrom
khasinski:fix-resolver-nil-state

Conversation

@khasinski
Copy link
Copy Markdown

Hi! Spotted this from a failing CI run on main (104 / 103 passed 1 errored).

Resolver#call splats **@state, but the constructor allows state to be nil (and there is even a test asserting resolver.state is nil by default). When a resolver is built without state, splatting nil raises TypeError: no implicit conversion of nil into Hash.

The fix is a one-liner: **(@state || {}). That keeps the documented default (nil state) while making the splat safe at call time.

Verified locally with bundle exec bake test: all 104 tests pass.

Splatting `**@state` raised `TypeError: no implicit conversion of nil into Hash`
when `Resolver.new` was constructed without state. Guard the splat with
`**(@State || {})` so the default `nil` state is preserved (per the existing
test) while still working at call time.
@khasinski
Copy link
Copy Markdown
Author

khasinski commented Apr 25, 2026

Quick note on the red checks, none of them are caused by this patch:

  • check (RuboCop): 467 offenses, all in examples/ (mostly Layout/ConsistentBlankLineIndentation). Same job already fails on main with 465 offenses, so it's pre-existing. lib/lively/resolver.rb itself is clean (no offenses detected).
  • jruby on ubuntu: infra issue. JRuby 10.1 needs Java 21 but the runner image has an older one, and the fallback then fails building the rbs native extension. Unrelated to the Ruby code in this PR.
  • truffleruby on ubuntu: 96 passed, 8 errored, but the errors are things like NoMethodError: undefined method 'scheduler' for class Fiber and TypeError: no implicit conversion of nil into String inside fixtures. resolver.rb does not show up in any of those traces.

All MRI Ruby test jobs (3.3, 3.4, 4.0 on macOS and Ubuntu, plus head on Ubuntu) are green, including the 3.3 on macOS job that was failing on main with the original TypeError this PR fixes.

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.

1 participant