soutaro / steep

Static type checker for Ruby
MIT License
1.35k stars 85 forks source link

bug: steep check raises unhandled exceptions #725

Open chozandrias76 opened 1 year ago

chozandrias76 commented 1 year ago

Reproduction Steps

Run `steep check` https://gist.github.com/chozandrias76/34e5789b877326eeac29203e159830b0
MECU commented 1 year ago

I have the same thing happening on Ruby 3.1.3.

Before the output listed in the above gist, I also have:

W, [2023-03-02T15:50:49.916383 #1845]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.919457 #1846]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.922623 #1847]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.932749 #1848]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.936870 #1849]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.941086 #1850]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.945363 #1851]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.961166 #1852]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.985545 #1853]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:49.997700 #1854]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`
W, [2023-03-02T15:50:50.331215 #1829]  WARN -- rbs: `set` has been moved to core library, so it is always loaded. Remove explicit loading `set`

And after the above gist, I see one . and it just hangs until I abort it. Here's the output after aborting: https://gist.github.com/MECU/384404a33b9ffb9e6475188dc4595e33

soutaro commented 1 year ago

Ah, this is caused by the incompatible changes introduced in RBS 3.0.

Please pin RBS in your Gemfile gem "rbs", "~> 2.8.0" for a while. I've been working to make Steep compatible with RBS 3.0, but it's not completed yet. (I also found some (non-trivial) problems in RBS 3.0.2 and working for it before Steep...)

chozandrias76 commented 1 year ago

Ah, this is caused by the incompatible changes introduced in RBS 3.0.

Please pin RBS in your Gemfile gem "rbs", "~> 2.8.0" for a while. I've been working to make Steep compatible with RBS 3.0, but it's not completed yet. (I also found some (non-trivial) problems in RBS 3.0.2 and working for it before Steep...)

Adding that line to my gemfile does not allow steep check to complete successfully when passed the Steepfile contains

target :test do
  signature "sig", "sig-private"

  check "app/models/*.rb"

  # library "pathname", "set"       # Standard libraries
end

and user.rbs

class User < ApplicationRecord
end
soutaro commented 1 year ago

Adding that line to my gemfile does not allow steep check to complete successfully when passed the Steepfile contains

@chozandrias76 Could you share the error messages?

I will make another release -- 1.3.1 -- that requires rbs-2.8.x (< 3.0.0) to avoid this confusion.

soutaro commented 1 year ago

Released Steep 1.3.1 that requires rbs ~> 2.8.0. I notice RBS > 2.8.2 has a regression that fails the tests on CI. You may want to add an explicit requirement in your Gemfile.

gem "rbs", "<=2.8.1"
chozandrias76 commented 1 year ago

Adding that line to my gemfile does not allow steep check to complete successfully when passed the Steepfile contains

@chozandrias76 Could you share the error messages?

I will make another release -- 1.3.1 -- that requires rbs-2.8.x (< 3.0.0) to avoid this confusion.

Its the hidden link on my first post

soutaro commented 1 year ago

@chozandrias76 Thanks. So, the error is:

[Steep 1.3.0] [typecheck:typecheck@0] [background] Unexpected error: #<NoMethodError: undefined method `reject' for #<RBS::Environment @declarations=(921 items) @class_decls=(312 items) @class_alias_decls=(0 items) @interface_decls=(29 items) @type_alias_decls=(20 items) @constant_decls=(569 items) @global_decls=(51 items)>>

It looks like this is because RBS 3.0 is loaded while Steep 1.3.0 doesn't support the version. (Environment#reject is removed in 3.0.)

How is the result of bundle info rbs?

chozandrias76 commented 1 year ago

@soutaro

Installing rbs 2.8.1 (was 2.8.4) with native extensions
Using steep 1.3.0
Using syntax_tree-rbs 0.5.1
Using prettier 3.2.2
Cleaning all the gems on your system is dangerous! If you're sure you want to remove every system gem not in this bundle, run `bundle clean --force`.

/Users/crashoverride/work/ledger [git::PROD-2499-add-steep-to-our-application *] [crashoverride@Colins-MacBook-Pro] [13:33]
> bundle info rbs
  * rbs (2.8.1)
        Summary: Type signature for Ruby.
        Homepage: https://github.com/ruby/rbs
        Source Code: https://github.com/ruby/rbs.git
        Changelog: https://github.com/ruby/rbs/blob/master/CHANGELOG.md
        Path: /Users/crashoverride/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/rbs-2.8.1

/Users/crashoverride/work/ledger [git::PROD-2499-add-steep-to-our-application *] [crashoverride@Colins-MacBook-Pro] [13:33]
> steep check sig/user.rbs
# Type checking files:

[Steep 1.3.0] [typecheck:typecheck@0] [background] Unexpected error: #<NoMethodError: undefined method `reject' for #<RBS::Environment @declarations=(921 items) @class_decls=(312 items) @class_alias_decls=(0 items) @interface_decls=(29 items) @type_alias_decls=(20 items) @constant_decls=(569 items) @global_decls=(51 items)>>
chozandrias76 commented 1 year ago

@soutaro any updates or anything else I can provide to help?