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

Conflict resolver doesn't handle type signatures contained in a separate RBI file to the main code #115

Open
Bo98 opened this issue May 14, 2021 · 3 comments · May be fixed by #119
Open
Labels
bug Something isn't working

Comments

@Bo98
Copy link

Bo98 commented May 14, 2021

Describe the bug
Sometimes type signatures are not defined inline in the main code but are defined in a separate RBI file with the same name.

For example: a file called mod.rb, which itself has a # typed: strict comment, might not actually have any type signatures stored inline but instead may have it in mod.rbi that sits alongside.

To Reproduce
Create a mod.rb with the following contents:

# typed: strict

module TestModule
  def self.some_method(arg)
    puts arg
  end
end

Then create a mod.rbi with the following contents:

# typed: strict

module TestModule
  include Kernel

  sig { params(arg: String).void }
  def self.some_method(arg); end
end

Note that srb tc will pass without errors here - it picks up the RBI and merges the type signatures into the main file.

Expected behavior
The Parlour conflict resolver handles this without errors.

Actual behavior

Parlour debug: Class: Registered
Parlour debug: conflict resolver: ├─ Resolving conflicts for <anonymous namespace>...
Parlour debug: conflict resolver: │  ├─ Checking children named TestModule...
Parlour debug: conflict resolver: │  │  ├─ Possible conflict between 2 objects
Parlour debug: conflict resolver: │  │  └─ Children are all mergeable; resolving automatically
Parlour debug: conflict resolver: │  ├─ Resolving children...
Parlour debug: conflict resolver: │  ├─ Resolving conflicts for TestModule...
Parlour debug: conflict resolver: │  │  ├─ Checking children named some_method...
Parlour debug: conflict resolver: │  │  │  ├─ Possible conflict between 2 objects
Parlour debug: conflict resolver: │  │  │  └─ Unable to resolve automatically; requesting manual resolution

Additional information
Parlour 6.0.0

@Bo98 Bo98 added the bug Something isn't working label May 14, 2021
@rodrigovilina
Copy link

@Bo98 Is there any known workarounds? I'm having the same issue.

@AaronC81
Copy link
Owner

AaronC81 commented Jul 3, 2021

Apologies it's taken me so long to respond to this! I totally missed the notification the first time around, it was the new comment which brought this back into my inbox.

I agree this should merge fine, I'll look into fixing this up.

@Bo98 @vaporyhumo As a workaround, you could use a .parlour file to tell the parser to include only the RBI files you'd like to merge together, which will exclude those Ruby files which it's conflicting with:

output_file:
  rbi: output.rbi

parser:
  included_paths:
    - ./lib/mod.rbi

@rodrigovilina
Copy link

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants