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 function application with implicit object #84

Merged
merged 1 commit into from Dec 26, 2022
Merged

Fix function application with implicit object #84

merged 1 commit into from Dec 26, 2022

Conversation

lorefnon
Copy link
Contributor

Passing implicit (not brace delimited) object to a function as first parameter has some oddities currently.

Something like this appears to work in basic example:

foo
 a: 10
foo(
 {a: 10},)

But if one more property is added things get weird:

foo
 a: 10
 b: 20
foo(
 {a: 10(
 {b: 20},)},)

Making the function invocation explicit through parens doesn't help:

foo(
 a: 10
 b: 20
)
foo(
 {a: 10(
 {b: 20})}
)

But interestingly if I add a space, then it is parsed as an implicit function application whose argument is a parenthesized implicit object expression, which works:

foo (
 a: 10
 b: 20
) 
foo(( {
 a: 10,
 b: 20,
}
))

This PR adds an additional rule so the first two scenarios also behave as expected.

@@ -85,6 +85,8 @@ ArgumentsWithTrailingCallExpressions
ArgumentList
ArgumentPart ( __ Comma ( NestedImplicitObjectLiteral / NestedArgumentList ) )+
# NOTE: Added nested arguments on separate new lines
InsertNewline InsertIndent NestedImplicitObjectLiteral ->
Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave out the InsertNewline and InsertIndent

@STRd6 STRd6 merged commit b0e3a0d into DanielXMoore:master Dec 26, 2022
@STRd6
Copy link
Contributor

STRd6 commented Dec 26, 2022

I made some minor changes here: 8a5e632

@lorefnon
Copy link
Contributor Author

@STRd6 Thank you - that looks better.

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

Successfully merging this pull request may close these issues.

None yet

2 participants