Skip to content

Sema: Never record argument label mismatches for unlabeled trailing closures #82020

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 2 commits into from
Jun 7, 2025

Conversation

AnthonyLatsis
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis commented Jun 5, 2025

Fixes a crash on invalid. The previous logic was causing a label mismatch constraint fix to be recorded for an unlabeled trailing closure argument matching a variadic paramater after a late recovery argument claim in matchCallArgumentsImpl, because the recovery claiming skips arguments matching defaulted parameters, but not variadic ones. We may want to reconsider that last part, but currently it regresses the quality of some diagnostics, and this is a targeted fix.

The previous behavior is fine because the diagnosis routine associate with the constraint fix (diagnoseArgumentLabelError) skips unlabeled trailing closures when tallying labeling issues — unless there are no other issues and the tally is zero, which we assert it is not.

Minimal crasher:

func f(x: Int...) {}
f { return () }

Fixes rdar://152313388.

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test macOS

…losures

Fixes a crash on invalid. The previous logic was causing a label
mismatch constraint fix to be recorded for an unlabeled trailing closure
argument matching a variadic paramater after a late recovery argument
claim in `matchCallArgumentsImpl`, because the recovery claiming skips
arguments matching defaulted parameters, but not variadic ones. We may
want to reconsider that last part, but currently it regresses the
quality of some diagnostics, and this is a targeted fix.

The previous behavior is fine because the diagnosis routine associate
with the constraint fix (`diagnoseArgumentLabelError`) skips unlabeled
trailing closures when tallying labeling issues — *unless* there are no
other issues and the tally is zero, which we assert it is not.

Fixes rdar://152313388.
@AnthonyLatsis
Copy link
Collaborator Author

AnthonyLatsis commented Jun 5, 2025

Heyyy, Hamish compiler crash fixed!

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please test source compatibility

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test Linux

@AnthonyLatsis
Copy link
Collaborator Author

Source compatibility failures not related, reproduce with main too.

@AnthonyLatsis AnthonyLatsis merged commit d10dfb3 into swiftlang:main Jun 7, 2025
3 of 5 checks passed
@AnthonyLatsis AnthonyLatsis deleted the camellia-sinensis branch June 7, 2025 16:08
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