-
Notifications
You must be signed in to change notification settings - Fork 28
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
Compiler crash for Parameter Packs: Incorrect reconstructed type
#5563
Comments
The log URL you attached seems something different to me |
swift-wasm 5.9.1 will encounter a compiler crash for Parameter Packs See swiftwasm/swift#5563
Fixed. |
Add more swift version for a test:
|
I think that's because we build compilers with assertions conservatively. Your code triggered ABI violation assertion, so I think it's slightly broken on other platforms as well at runtime even it passes compilation. |
I thought we only have stable ABI on Darwin platform 🤔.
Which rule do I break? I can normally run Unit Tests target of the package on Linux, macOS and iOS. They all seem fine. |
It's an issue in compiler that misses type coercion for nested unpacked tuple. Please try replacing |
Sorry, I couldn't reproduce on my end. I think disabling the assertion by adding |
Thanks. I'll give it a try.
I believe the following snipest can reproduce it. public protocol View {
associatedtype Body: View
@ViewBuilder
@MainActor
var body: Self.Body { get }
}
extension Never: View { public var body: Never { fatalError() } }
protocol PrimitiveView: View where Body == Never {}
extension PrimitiveView {
public var body: Never { fatalError() }
}
@frozen
public struct TupleView<T>: PrimitiveView {
public var value: T
@inlinable public init(_ value: T) { self.value = value }
public typealias Body = Never
}
@resultBuilder
public enum ViewBuilder {
@_alwaysEmitIntoClient
public static func buildExpression<Content>(_ content: Content) -> Content where Content: View {
content
}
@_alwaysEmitIntoClient
public static func buildBlock<Content>(_ content: Content) -> Content where Content: View {
content
}
@_disfavoredOverload
@_alwaysEmitIntoClient
public static func buildBlock<each Content>(_ content: repeat each Content) -> TupleView < (repeat each Content)> where repeat each Content: View {
TupleView((repeat each content))
}
} |
Thanks, but it doesn't reproduce. Please ensure that |
Haven't installed Wasm Swift SDK locally before. I'll give it a shot this weekend and report the minimum reproducible code later. |
Building for debugging...
/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:3944:141: error: cannot specialize non-generic type 'Collection' (aka 'OpaquePointer')
public mutating func replaceSubrange(_ subrange: Swift.Range<Foundation.AttributedString.UnicodeScalarView.Index>, with newElements: some Collection<UnicodeScalar>)
^ ~~~~~~~~~~~~~~~
/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:11963:137: error: cannot specialize non-generic type 'Collection' (aka 'OpaquePointer')
public mutating func replaceSubrange(_ subrange: Swift.Range<Foundation.AttributedString.CharacterView.Index>, with newElements: some Collection<Character>)
^ ~~~~~~~~~~~
/Applications/Xcode-15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/OSLog.swiftmodule/arm64e-apple-macos.swiftinterface:5:8: error: failed to build module 'Foundation'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.9.2 (swiftlang-5.9.2.2.11 clang-1500.1.0.2.2)', while this compiler is 'SwiftWasm Swift version 5.9.1 (swift-5.9.1-RELEASE)'). Please select a toolchain which matches the SDK.
import Foundation This compile error would be fixed in Swift 5.9.2
I'd like to try the same env of the CI - Ubuntu 22 here. But my Linux env is aarch64 Ubuntu 22 and there is no such wasm SDK to download currently. I'll set up a x86_64 Ubuntu 22 to give it a try. |
Set up a x86_64 Ubuntu 22 locally and I can reproduce the bug both with OpenSwiftUI package and the snippets package I post above with Using kyle@ubuntu-amd64:/DemoKit/Sources/DemoKit$ swift --version
SwiftWasm Swift version 5.9.1 (swift-5.9.1-RELEASE)
Target: x86_64-unknown-linux-gnu
kyle@ubuntu-amd64:/DemoKit/Sources/DemoKit$ swiftc -frontend -c DemoKit.swift -target wasm32-unknown-wasi
<unknown>:0: warning: glibc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
kyle@ubuntu-amd64:/DemoKit/Sources/DemoKit$ l
DemoKit.o DemoKit.swift In summary, the current build matrix:
On my side, I'm consider using macOS container as CI or use the latest wasm-DEVELOPMENT-SNAPSHOT + Ubuntu as a workaround while waiting for a upstream investigation. |
At this moment, please use |
Thanks. It works. I'll update my CI script to fix it. |
* Add wasm CI support * Add more swift versions for wasm swift-wasm 5.9.1 will encounter a compiler crash for Parameter Packs See swiftwasm/swift#5563 * Fix the upstream compiler error
Incorrect reconstructed type
I'm adding WASM CI to some of my packages. And I noticed some Parameter Packs related compiler crash here. (The feature was introduced in Swift 5.9)
The reproducible code
See full log here
https://github.com/OpenSwiftUIProject/OpenSwiftUI/actions/runs/7640702278/job/20816373359?pr=27
The text was updated successfully, but these errors were encountered: