Skip to content

Conversation

@ultramiraculous
Copy link
Contributor

@ultramiraculous ultramiraculous commented Dec 10, 2025

In #65125 (and beyond) matchTypes, has logic to attempt to wrap an incoming parameter in a tuple under certain conditions that might help with type expansion.

In the case the incoming type was backed by a var, it would be wrapped by an LValueType then be subsequently mis-diagnosed as not-a-tuple.

More details in #85924 , this this is also the cause of (and fix for) #85837 as well...

if (isa<TupleType>(desugar1) != isa<TupleType>(desugar2) &&

// Ignore the l-valueness when checking for wrapping
bool type1IsTuple = desugar1->getWithoutSpecifierType()->is<TupleType>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously isa<TupleType> would always return false when it it the LValueType, leading to this check erroneously passing:

isa<TupleType>(desugar1) != isa<TupleType>(desugar2)

In my examples the left value would not be diagnoised as a tuple here or in the subsequent matchTypes nested call, leading to a TupleType getting allocated with just the @lValue type.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think unwrapping is the right move here, I think we just need to delay this just like we did for InOutType down below with !isa<LValueType>(desugar1) && !isa<LValueType>(desugar2) && because match types would handle LValue -> RValue and LValue -> LValue type already by recursively calling itself.

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 yeah I think I found the conversion code when I was trying to find getWithoutSpecifierType but didn't register what it was for.

Let me see if that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the tests still pass with this change (and fail without it, thank god 😅)!

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect :)

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

This looks reasonable, I think. Maybe @xedin can give a second opinion

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@ultramiraculous
Copy link
Contributor Author

@slavapestov I updated the comments as mentioned, but also realized I forgot to change a test name. This might need another @swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@xedin
Copy link
Contributor

xedin commented Dec 11, 2025

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Dec 12, 2025

@swift-ci please test Windows platform

@xedin xedin enabled auto-merge (squash) December 12, 2025 01:36
@xedin xedin merged commit fe0191c into swiftlang:main Dec 12, 2025
5 checks passed
ultramiraculous added a commit to ultramiraculous/swift that referenced this pull request Dec 12, 2025
…e `LValueType`s to not be tuples (swiftlang#85962)

In swiftlang#65125 (and beyond) `matchTypes`, has logic to attempt to wrap an
incoming parameter in a tuple under certain conditions that might help
with type expansion.

In the case the incoming type was backed by a `var`, it would be wrapped
by an `LValueType` then be subsequently mis-diagnosed as not-a-tuple.

More details in swiftlang#85924 , this this is also the cause of (and fix for)
swiftlang#85837 as well...
slavapestov added a commit that referenced this pull request Dec 13, 2025
[6.3][CSSimplify] Parameter pack wrapping logic incorrectly considers tuple LValueTypes to not be tuples #85962
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.

3 participants