Skip to content

Allow implicit call with class with no body #5053

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

Merged

Conversation

helixbass
Copy link
Collaborator

Fixes #5052

Tweaks addImplicitBracesAndParens() to correctly close an inline implicit call which has an argument that's a class with no body

So now eg f class A compiles

The issue was that it was generating the implicit opening ( but failing to generate the closing ) at the end of the line since when it saw class it pushed a CONTROL token that expected to see an INDENT-OUTDENT pair before unblocking the closing of the implicit call

@Inve1951
Copy link
Contributor

Inve1951 commented May 4, 2018

this syntax for a function call used in the test is currently a hack

f
  b: 1
  class A
  a

@helixbass
Copy link
Collaborator Author

@Inve1951 what do you mean exactly? I included that test case to check that in a multiline implicit call (with an implicit object first argument) the new code didn't trigger a premature ending of the implicit call

@Inve1951
Copy link
Contributor

Inve1951 commented May 5, 2018

@helixbass The only time where the compiler allows for a function call where the arguments start on a new line is when the first argument is an implicit object. All of the following examples throw at compile time with unexpected indentation:

f
  a

f
  class A

f
  1
  b: 3

f
  {b: 3}

@helixbass
Copy link
Collaborator Author

@Inve1951 yup the fact that an indented implicit object as the first arg can start an implicit call is a special case. That's why I thought it was worth testing since it's a different way for an implicit call and an "inline" class to interact

@GeoffreyBooth
Copy link
Collaborator

@Inve1951 or anyone else, is this okay to merge in?

@Inve1951
Copy link
Contributor

I'm good with it. My only concern is that the test relies on the implicit object starting a call, which I'm not sure about whether that's a supported feature or not. But I'm certainly in favor to have that as a language feature. In fact I'd expect the same from the broken cases I demonstrated in my previous comment.

@vendethiel
Copy link
Collaborator

My only concern is that the test relies on the implicit object starting a call, which I'm not sure about whether that's a supported feature or not.

It's very much a special case. Your "broken cases" do not compile on purpose.

@GeoffreyBooth
Copy link
Collaborator

@vendethiel are there any issues with this PR, or is it okay to merge in?

@vendethiel
Copy link
Collaborator

I'm very bad at rewriter stuff, it the tests pass then I'd say go for it.

@GeoffreyBooth GeoffreyBooth merged commit 7dbdca8 into jashkenas:master May 13, 2018
@GeoffreyBooth GeoffreyBooth mentioned this pull request May 20, 2018
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.

Bug: implicit call of class with no body fails
4 participants