Skip to content

Conversation

@naveen-seth
Copy link
Contributor

@naveen-seth naveen-seth commented Nov 10, 2025

This fixes a compiler crash that occurred when diagnosing an ambiguous call using trailing closure syntax, where one of the candidates was a function or initializer with no parameters.

The crash was caused by calling .back() on the candidate's empty parameter list, which is now guarded against.

Resolves #85364, resolves #85378.

Fixes swiftlang#85376.

This fixes a compiler crash that occurred when diagnosing an ambiguous call
using trailing closure syntax, where one of the candidates was a function or
initializer with no parameters.
@xedin
Copy link
Contributor

xedin commented Nov 10, 2025

Thank you @naveen-seth! I will take a look tomorrow!

return false;

const ParameterList *paramList = callee->getParameters();
if (paramList->getArray().empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change this condition to (!paramList || paramList->size() == 0) and paramList->getArray().back() could be changed to paramList->back() while we are here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thank you for reviewing!

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Thank you!

@xedin
Copy link
Contributor

xedin commented Nov 10, 2025

@swift-ci please smoke test

@xedin
Copy link
Contributor

xedin commented Nov 10, 2025

@naveen-seth Looks like you need to mark validation-test/compiler_crashers/TrailingClosureAmbiguityFailure-diagnoseAsNote-d62041.swift as fixed as well.

@xedin
Copy link
Contributor

xedin commented Nov 10, 2025

@swift-ci please smoke test

@naveen-seth
Copy link
Contributor Author

naveen-seth commented Nov 11, 2025

@naveen-seth Looks like you need to mark validation-test/compiler_crashers/TrailingClosureAmbiguityFailure-diagnoseAsNote-d62041.swift as fixed as well.

Ah, I see! For future reference, should I have just extended the test in validation-test/... instead? (I can still do that.)

And in general, should all regression checks that guard against crashes be added under validation-test/compiler-crashers(-fixed)? I wasn’t entirely sure about that from the docs.

@xedin
Copy link
Contributor

xedin commented Nov 11, 2025

@naveen-seth Yes, you can move your test case to the same place and use issue-<number>.swift for the name.

@naveen-seth naveen-seth requested a review from xedin November 11, 2025 20:40
@xedin
Copy link
Contributor

xedin commented Nov 11, 2025

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Nov 12, 2025

@swift-ci please test Windows platform

@xedin xedin merged commit 4d8d719 into swiftlang:main Nov 12, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants