-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow implicit call with class with no body #5053
Conversation
this syntax for a function call used in the test is currently a hack f
b: 1
class A
a |
@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 |
@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 f
a
f
class A
f
1
b: 3
f
{b: 3} |
@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 |
@Inve1951 or anyone else, is this okay to merge in? |
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. |
It's very much a special case. Your "broken cases" do not compile on purpose. |
@vendethiel are there any issues with this PR, or is it okay to merge in? |
I'm very bad at rewriter stuff, it the tests pass then I'd say go for it. |
Fixes #5052
Tweaks
addImplicitBracesAndParens()
to correctly close an inline implicit call which has an argument that's a class with no bodySo now eg
f class A
compilesThe issue was that it was generating the implicit opening
(
but failing to generate the closing)
at the end of the line since when it sawclass
it pushed aCONTROL
token that expected to see anINDENT
-OUTDENT
pair before unblocking the closing of the implicit call