-
-
Notifications
You must be signed in to change notification settings - Fork 100
Prettier swallows parenthesis when doing pattern matching #1018
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
Comments
Hmm looks like it creates a bug only in the |
No no, parenthesis must be maintained in order to properly match the array elements Here is the tests how it should work:
When parenthesis are there in every |
Doesn't this pass your tests? class Test
def compose_words(words)
case words
in first, second
words.join(" i ")
in [first]
words[0]
in *something, second, first
[something.join(", "), [second, first].join(" i ")].join(", ")
else
""
end
end
end |
Oh right, it does! |
TIL, I actually did not know that you can omit the parenthesis to properly match multiple array elems |
Wow, that was fast! Big thanks @kddnewton :) |
Metadata
Operating system: macOS Catalina
Ruby version: 3.0.2
Node version: v14.17.6
@prettier/plugin-ruby
orprettier
gem version: @prettier/plugin-ruby@2.0.0-rc4Options:
rubyArrayLiteral
-true
rubyHashLabel
-true
rubyModifier
-true
rubySingleQuote
-false
rubyToProc
-false
trailingComma
-"all"
Input
Current output
Expected output
Removal of square parenthesis caused the code to be bugged
The text was updated successfully, but these errors were encountered: