-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Crash at compilation when calling variadic generic function using pack expansion as argument #67645
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
Comments
It no longer crashes for me on main, but I get this diagnostic:
@xedin Is this a known issue? |
You are right, I have built my test project with the main nightly and it does not crash anymore. Will try to torture this piece of code again soon |
I found another crash, I am not sure if I should create another issue. @discardableResult
func foo<each Arg, each Name: StringProtocol>(
named: (repeat each Name),
fn: @escaping (repeat each Arg) -> Void
) -> (repeat ((each Arg).Type, each Name)) {
let tuple = (repeat ((each Arg).self, each named))
return tuple
} Note that making the type of tuple explicit doesn't help with stack trace:
The snippets which return directly the tuple instead of putting it in a variable works as expected @discardableResult
func foo<each Arg, each Name: StringProtocol>(
named: (repeat each Name),
fn: @escaping (repeat each Arg) -> Void
) -> (repeat ((each Arg).Type, each Name)) {
return (repeat ((each Arg).self, each named))
}
func bar(int: Int, bool: Bool) -> Void {}
print(foo(named: ("a", "b"), fn: bar)) Output: Environment Toolchain : swift-DEVELOPMENT-SNAPSHOT-2023-08-12-a for macOS |
I don't think I saw this one before. |
I just tested with swift-DEVELOPMENT-SNAPSHOT-2023-08-23-a:
@discardableResult
func foo<each Name: StringProtocol, each Arg>(
named: (repeat each Name),
fn: @escaping (repeat each Arg) -> Void
) -> (repeat ((each Arg).Type, each Name)) {
let tuple: (repeat ((each Arg).Type, each Name)) = (repeat ((each Arg).self, each named))
return tuple
//return (repeat ((each Arg).self, each named))
}
func bar(int: Int, bool: Bool) -> Void {}
print(foo(named: ("a", "b"), fn: bar)) Version 15.0 beta 7 (15A5229h) One line return statement is working in all cases. |
@simanerush I saw a similar error in #71258. |
I have this commit sitting in my local repo since forever. @simanerush feel free to land it with a test case. I don't even remember if it works though!
|
@slavapestov Thank you, I'll take a look! |
… positions Fixes part of swiftlang#67645, rdar://119267393
@simanerush Could you open a new issue for the tuple crash? The original issue is unrelated and fixed. |
@AnthonyLatsis will do, thank you! |
… positions Fixes part of swiftlang#67645, rdar://119267393
… positions Fixes part of #67645, rdar://119267393
Description
Compiling the code below result in a crash / fatalError of the compiler.
Steps to reproduce
Expected behavior
Compiler doesn't crash and produce an error message.
Environment
Weird/Interesting things
Using the same snippet, try to exchange the order of foo generic parameters like this :
func foo<each Name: StringProtocol, each Arg>
, the compiler doesn't crash anymore and produce a different error message.Xcode:
Command line still produce fatalError but the same error message:
Finally: making
named
parameter a tuple, never result in a crash but inverting the generic parameter still product different error messages.The text was updated successfully, but these errors were encountered: