-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Parameter packs and passing tuples as arguments crashes Swift #78646
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
Comments
Lancelotbronner
added
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
labels
Jan 15, 2025
See also the Swift Forums post. Additional example, adding the struct causes the crash. func call<each Arg, Result, Failure>(
_ f: (repeat each Arg) throws(Failure) -> Result,
with args: (repeat each Arg)
) throws(Failure) -> Result {
try f(repeat each args)
}
func test(x:Int,y:Int,z:Int) -> String {
"\(x),\(y),\(z)"
}
print(call(test, with: (1,2,3)))
struct Executer<each Arg, Result, Failure: Error> {
let task: (repeat each Arg) throws(Failure) -> Result
func execute(with args: (repeat each Arg)) throws(Failure) {
try call(task, with: args)
}
}
print(Executer(task: test).execute(with: (2,3,5))) |
Not sure if this is the same crash, but got another failing snippet: public protocol Parser<Input, Output, ParsingFailure> {
associatedtype Input
associatedtype Output
associatedtype ParsingFailure: Error
func parse(_ input: inout Input) throws(ParsingFailure) -> Output
}
public extension Failures {
struct Many<UnderlyingFailure: Error>: Error {
public var underlyingFailures: [UnderlyingFailure]
@usableFromInline
init(underlyingFailures: [UnderlyingFailure]) {
self.underlyingFailures = underlyingFailures
}
@usableFromInline
init(reserveCapacity minimumCapacity: Int) {
underlyingFailures = []
underlyingFailures.reserveCapacity(minimumCapacity)
}
}
}
@usableFromInline
struct OneOfMany<Parsers: Parser>: Parser {
public typealias ParsingFailure = Failures.Many<Parsers.ParsingFailure>
@usableFromInline
var parsers: [Parsers]
@usableFromInline
init(_ parsers: [Parsers]) {
self.parsers = parsers
}
@inlinable
func parse(_ input: inout Parsers.Input) throws(ParsingFailure) -> Parsers.Output {
let original = input
for parser in parsers.dropLast() {
do {
return try parser.parse(&input)
} catch {
input = original
}
}
if let parser = parsers.last {
do {
return try parser.parse(&input)
} catch {
}
}
fatalError()
}
}
|
This was referenced Jan 16, 2025
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.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
Description
I'm playing with
swift-parsing
and parameter packs.I think what I'm trying to do may also crash at runtime.
Reproduction
Stack dump
Expected behavior
I'm not sure if this should compile, so either an error or successful compilation.
Environment
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Additional information
No response
The text was updated successfully, but these errors were encountered: