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

Ignoring overloads after the first in method comments #36

Closed
euglena1215 opened this issue May 28, 2024 · 4 comments
Closed

Ignoring overloads after the first in method comments #36

euglena1215 opened this issue May 28, 2024 · 4 comments

Comments

@euglena1215
Copy link

Description

When using #:: comments to express method overloads, everything after the first | is ignored.

Steps to Reproduce

Run rbs-inline on the following program:

#:: (String) -> String | (Integer) -> Integer
def foo(x)
  x
end

Expected Result

The following should be generated:

#:: (String) -> String | (Integer) -> Integer 
def foo: (String) -> String | (Integer) -> Integer

Actual Result

Everything after the first | is ignored, resulting in:

#:: (String) -> String | (Integer) -> Integer 
def foo: (String) -> String

Environment

  • rbs-inline: 0.3.0
@soutaro
Copy link
Owner

soutaro commented May 29, 2024

The syntax accepts only one overload. So, having another overload after the | token doesn't work.

@ParadoxV5
Copy link

Is this the current way to write overloads?

#:: (String) -> String
#:: (Integer) -> Integer

Perhaps OP’s expectation is more explicit?

#:: (String) -> String
# | (Integer) -> Integer

@soutaro
Copy link
Owner

soutaro commented May 29, 2024

Hmm...
Yeah, it's possible.

@euglena1215
Copy link
Author

Oh, thank you very much. It seems to work as expected with the following.

#:: (String) -> String
#:: (Integer) -> Integer

I also found the following on the Wiki:

Having multiple #:: syntax generates method definition with overloads.

My issue was not so much a syntax problem, but rather that I felt rbs-inline could not express overloads. I will close this issue now that I know I was mistaken.

Thank you for your comments!

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

No branches or pull requests

3 participants