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

Keyword arg with default cannot reference a previous positional arg with default #2056

Open
seven1m opened this issue May 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@seven1m
Copy link
Member

seven1m commented May 31, 2024

Because of the way we build our argument instructions, the following code produces a compilation error:

https://github.com/rack/rack/blob/main/lib/rack/multipart/uploaded_file.rb#L16-L17

Basically, you cannot have this:

def foo(a = 1, b: a)
end

I have half a mind to rewrite our Args class. When I wrote that, I didn't have good information from the parser, and I thought the only way to consume the arguments properly was to build a sort of state machine.

Now Prism gives us much better information, i.e.:

node.requireds
node.rest
node.optionals
node.posts
node.keywords
node.keyword_rest
node.block

I think using this information (vs what we do now, which is to basically smoosh them together) will greatly simplify that class and allow us to consume the arguments in order, thus fixing this bug. 🤞

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

No branches or pull requests

1 participant