Skip to content

Fix parsing invalid function parameters #2927

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
merged 1 commit into from
Feb 18, 2025

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Dec 23, 2024

Fixes #2254

@kimdv kimdv force-pushed the kimdv/fix-issue-2254 branch 2 times, most recently from 49cbb92 to a5831b5 Compare December 23, 2024 21:24
@kimdv
Copy link
Contributor Author

kimdv commented Dec 23, 2024

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me. I think just a few tests need to be updated.

@kimdv
Copy link
Contributor Author

kimdv commented Jan 4, 2025

Thanks. Looks good to me. I think just a few tests need to be updated.

Not sure what is right.
We have the test case testInitAccessorsWithDefaultValues.

It will change init(initialValue: <#type#>) {} -> init(<#identifier#>: initialValue) {}.

I think this is more wrong.

Would it make sense to assume that if it starts with a lower case, it's an identifier and if it starts with an uppercase it's a type?

@ahoppen
Copy link
Member

ahoppen commented Jan 5, 2025

Would it make sense to assume that if it starts with a lower case, it's an identifier and if it starts with an uppercase it's a type?

I think that’s very reasonable behavior for error recovery. I have wanted to do this in some case in the past but I think that change never made to to a PR.

@kimdv
Copy link
Contributor Author

kimdv commented Jan 22, 2025

Would it make sense to assume that if it starts with a lower case, it's an identifier and if it starts with an uppercase it's a type?

I think that’s very reasonable behavior for error recovery. I have wanted to do this in some case in the past but I think that change never made to to a PR.

I was digging a bit into it.
Where do you think is a propper place, would it be canParseType()?

@ahoppen
Copy link
Member

ahoppen commented Jan 22, 2025

I would try shoving the uppercase check into the line that currently has.

 let canParseType = withLookahead { $0.canParseType() && $0.at(.comma, .rightParen) }

@kimdv kimdv force-pushed the kimdv/fix-issue-2254 branch from a5831b5 to dfbc52e Compare February 13, 2025 18:59
@kimdv
Copy link
Contributor Author

kimdv commented Feb 13, 2025

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thanks, Kim. This looks good to me.

@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2025

The macOS formatting failure is unrelated. We’re currently working on a fix, should be fixed tomorrow-ish, could you re-trigger CI then?

@kimdv
Copy link
Contributor Author

kimdv commented Feb 14, 2025

The macOS formatting failure is unrelated. We’re currently working on a fix, should be fixed tomorrow-ish, could you re-trigger CI then?

Yes no problem. Will rebase and re-trigger.

@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2025

For reference, this is the PR that fixes the format issue: swiftlang/swift#79380

@kimdv
Copy link
Contributor Author

kimdv commented Feb 17, 2025

@swift-ci please test

@kimdv kimdv merged commit 8ac9b96 into swiftlang:main Feb 18, 2025
3 checks passed
@kimdv kimdv deleted the kimdv/fix-issue-2254 branch February 18, 2025 11:55
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.

swift syntax should be able to recover function parameters without argument labels
3 participants