Skip to content
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

passing function result of a parameter pack to a generic function results in false compiler error. #73613

Open
JaapWijnen opened this issue May 14, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@JaapWijnen
Copy link
Contributor

JaapWijnen commented May 14, 2024

Description

Passing a parameter pack function result directly into a generic function that compares it to a parameter with the same type fails to compile.

Reproduction

struct V<each U> { }

func combine<each LHSU, each RHSU>(lhs: V<repeat each LHSU>, rhs: V<repeat each RHSU>) -> V<repeat each LHSU, repeat each RHSU> {
    .init()
}

func compareGeneric<T>(lhs: T, rhs: T) { } // doesn't actually compare anything

// fails to compile with error: Cannot convert value of type 'V<Int, Int, Int, String>' to expected argument type 'V<Int, Int, Int, String>'
// Which is the exact same type
func doThing() {
    compareGeneric(lhs: combine(lhs: V<Int, Int>(), rhs: V<Int, String>()), rhs: V<Int, Int, Int, String>())
}

// does compile by adding an intermediary variable to store the result of combine(lhs:rhs:)
//func doThing() {
//    let intermediary = combine(lhs: V<Int, Int>(), rhs: V<Int, String>())
//    compareGeneric(lhs: intermediary, rhs: V<Int, Int, Int, String>())
//}

Expected behavior

Expected to compile.

Environment

Fails on both:
6.0-DEVELOPMENT-SNAPSHOT-2024-04-30-a
Apple Swift version 6.0-dev (LLVM 7b8e6346027d2b1, Swift 763421c)
Target: arm64-apple-macosx14.0
and:
DEVELOPMENT-SNAPSHOT-2024-05-01-a
Apple Swift version 6.0-dev (LLVM b66077aefd3be08, Swift 84d3618)
Target: arm64-apple-macosx14.0

Additional information

No response

@JaapWijnen JaapWijnen added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant