Skip to content
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

Fix unexpected error when DifferentMethodParameterKind #917

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

ksss
Copy link
Contributor

@ksss ksss commented Sep 25, 2023

I encountered a pattern that was causing unexpected errors, so I have fixed it.
It seems that << takes precedence over ||.
This pattern was occurring with Ripper.tokenize.

https://github.com/ruby/ruby/blob/7816307b30189ec7d71d6ce704a9aebd0395d447/ext/ripper/lib/ripper/lexer.rb#L25

https://github.com/ruby/rbs/blob/abcc97d3c8b024856ba9603a7ef22d422652ff42/stdlib/ripper/0/ripper.rbs#L1097

Repro

$ cat t.rb
class Foo
  def foo(**kw)
  end
end

$ cat t.rbs
class Foo
  def foo: (?a: boolish) -> void
end

$ cat Steepfile
target :app do
  check "t.rb"
  signature "t.rbs"
end

$ steep check
# Type checking files:

......................................................................[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)] Unexpected error: RuntimeError
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/ast/types/union.rb:16:in `build'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/type_inference/method_params.rb:467:in `build'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/type_construction.rb:199:in `for_new_method'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/type_construction.rb:278:in `with_method_constr'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/type_construction.rb:942:in `block (2 levels) in synthesize'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   <internal:kernel>:148:in `yield_self'
[Steep 1.5.3] [typecheck:typecheck@2] [background] [#typecheck_source(path=t.rb)] [#type_check_file(t.rb@app)] [synthesize:(1:1)] [synthesize:(2:3)]   /Users/yuki.kurihara/src/github.com/ksss/steep/lib/steep/type_construction.rb:937:in `block in synthesize'
...(snip)

Copy link
Owner

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! 🙏

@soutaro soutaro added this to the Steep 1.6 milestone Oct 3, 2023
@soutaro soutaro merged commit 1f8d5ad into soutaro:master Oct 3, 2023
20 checks passed
@soutaro soutaro added the bug label Oct 3, 2023
@ksss ksss deleted the unexpected-keyrest-keyopt branch October 3, 2023 02:37
@soutaro soutaro added the Released The PR is already included in a published release label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Released The PR is already included in a published release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants