Skip to content

Fix loop breaking condition for dictionary literal parsing. #812

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

Closed

Conversation

sjavora
Copy link

@sjavora sjavora commented Sep 18, 2022

This resolves a FIXME I found in the tests - the loop break previously required the key AND colon AND value to be missing, which I don't think is even possible to satisfy.

@sjavora sjavora requested a review from ahoppen as a code owner September 18, 2022 10:59
@@ -1630,7 +1630,7 @@ extension Parser {
valueExpression: value,
trailingComma: comma,
arena: self.arena)))
if key.is(RawMissingExprSyntax.self), colon.isMissing, value.is(RawMissingExprSyntax.self) {
if key.is(RawMissingExprSyntax.self) || colon.isMissing || value.is(RawMissingExprSyntax.self) {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this is superior in general. IIUC if you have

[
  1: "one",
  2: ,
  3: "three"
]

we wouldn’t be stopping dictionary literal parsing at the missing value for 2 and thus not add 3: "three" to the string literal.

What do key and value contain when we synthesize the missing colon?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the pointer, I'll try to investigate further.

Interestingly, your example produces no diagnostics for me with the original implementation 😅

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I forgot that my example will only start producing diagnostics once #739 is merged.

@ahoppen
Copy link
Member

ahoppen commented Sep 20, 2022

I forgot that I already have a fix for this up as part of one of my PRs: 5731968. Because that fixes the issue, I’m closing this PR. Sorry.

@ahoppen ahoppen closed this Sep 20, 2022
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.

2 participants