-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
assertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
Given
struct Variadic<each T>: Sequence {
typealias Element = Int
typealias Iterator = [Int].Iterator
consuming func makeIterator() -> Iterator {
fatalError()
}
}
func foo<each T>(_: repeat each T) -> Variadic<repeat each T> {
.init()
}the following code is causing a compiler crash, with the error message Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 578 (Full output/stack dump),
for a in foo {
print(a)
}and the following one shows the error message Assertion failed: ((!replacement || replacement->hasError() || gp->isParameterPack() == replacement->is<PackType>()) && "replacement for pack parameter must be a pack type"), function operator(), file SubstitutionMap.cpp, line 237.
for a in foo() {
print(a)
}Steps to reproduce
Build the script with the latest Swift development snapshot.
Expected behavior
The compiler shouldn't crash.
Environment
- Swift compiler version info:
swift-DEVELOPMENT-SNAPSHOT-2023-08-09-a.xctoolchain, Apple Swift version 5.9-dev (LLVM79013835e88ccd5, Swiftcda0fd4c84d72a9) - Xcode version info: Xcode 14.2, Build version 14C18
- Deployment target: macOS 12.6.8 (21G725)
Additional context
The script compiles if you use an intermediate variable:
let s = foo()
for a in s {
print(a)
}Metadata
Metadata
Assignees
Labels
assertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsgenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis