Skip to content

Conversation

@slavapestov
Copy link
Contributor

This test case crashes when prepared overloads are disabled, but passes when enabled. To avoid messing up tests if we have to turn the flag on and off, fix the crash.

@slavapestov slavapestov enabled auto-merge October 20, 2025 21:07
@slavapestov slavapestov force-pushed the prepared-fuzz branch 3 times, most recently from cb58dd8 to eaa38f3 Compare October 20, 2025 22:50
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

for (auto &fix : contextualFixes)
genericParamInferredTypes.insert(fix.first->getFixedType(resultTypeVar));
for (auto &fix : contextualFixes) {
if (fix.first->hasFixedType(resultTypeVar))
Copy link
Contributor

Choose a reason for hiding this comment

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

Free type variables are allowed only with FreeTypeVariableBinding::Allow set, I think a better fix here might be to actually get an overload from every solution instead and extra their result type because if hasFixedType is ever produces true it could mean that overloads were chosen in sub-scope when solutions diverged.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is indeed the case:

Solution 1: locator@0xbb4859000 [OverloadedDeclRef@<stdin>:4:12] with Swift.(file).?? as ??: (consuming $T8?, @autoclosure () throws -> $T8) throws -> $T8

Solution 2: locator@0xbb4859000 [OverloadedDeclRef@<stdin>:4:12] with Swift.(file).?? as ??: (consuming $T17?, @autoclosure () throws -> $T17) throws -> $T17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! I’ll hold off on landing this until I figure out the right fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Slightly higher up is where we get an overload from the first fix, I think all you need to do here is just that for each of the solutions involved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

extra their result type

This should say "extract" right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sorry!

@slavapestov slavapestov disabled auto-merge October 20, 2025 23:51
@slavapestov slavapestov marked this pull request as draft October 20, 2025 23:51
This test case crashes when prepared overloads are disabled, but passes
when enabled. To avoid messing up tests if we have to turn the flag on
and off, fix the crash.
@slavapestov slavapestov marked this pull request as ready for review October 24, 2025 20:21
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@xedin Here is a new version that I think does what you asked, PTAL. I don't see any differences in diagnostic output and the fuzzer crash passes now just like the previous version. If you can think of any test cases to add, that would great, otherwise I'll go ahead and land this fix.

@slavapestov slavapestov enabled auto-merge October 24, 2025 21:04
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!

auto argParamMatch = argMatching->second.parameterBindings[i];

// FIXME: We're just looking at the first solution's overload here,
// is that correct?
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for now, the whole method expects the first overload with an issue to be generic which is not really correct but we can refactor that separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, I now understand what is going on here - the expectation is that the overload is the same across solutions and only generic parameter bindings are different…

@slavapestov slavapestov merged commit 3b1960e into swiftlang:main Oct 25, 2025
3 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

Development

Successfully merging this pull request may close these issues.

2 participants