-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add exception to delimiter logic for parenthesized with
syntax
#154
Conversation
with
expressionswith
syntax
tests/formatter.test.ts
Outdated
@@ -615,4 +615,11 @@ public type T = { | |||
await expectFormatted('?#abc\n'); | |||
expect(await format('? #abc')).toEqual('?#abc\n'); | |||
}); | |||
|
|||
test('parenthesized `with` expression', async () => { | |||
await expectFormatted('(x with a = 1);\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await expectFormatted('(x with a = 1);\n'); | |
await expectFormatted('(x with a = 1)\n'); |
These are never followed by a semi, as they are not expressions/statements. Instead they prefix expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe test await expectFormatted('(with a = 1)\n');
(and friends).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what you're saying. I'll update the tests so that it includes the following actor, since these cases are assumed to be (invalid) standalone expressions which end in trailing semicolons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, see:
$ rlwrap moc
Motoko compiler (source 0.13.7-202-g68eddf78f-dirty)
> (x with a = 1; b = 2);
stdin:1.22-1.23: syntax error [M0001], unexpected token ';', expected one of token or <phrase> sequence:
<obj_or_class_dec>
async <exp_nest>
<exp_post(ob)> <inst> <exp_nullary(ob)>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! THX!
Accounts for new syntax in dfinity/motoko#4812.