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

[SR-8109] Swift 4.2 Regression: Single-element tuple not prevented #50641

jepers opened this issue Jun 26, 2018 · 6 comments

[SR-8109] Swift 4.2 Regression: Single-element tuple not prevented #50641

jepers opened this issue Jun 26, 2018 · 6 comments


Copy link

@jepers jepers commented Jun 26, 2018

Previous ID SR-8109
Radar rdar://problem/41474370
Original Reporter @jepers
Type Bug
Status Closed
Resolution Done

Xcode 10 beta 1, Xcode 10 beta 2, recent dev snapshots

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression
Assignee None
Priority Medium

md5: a1a43661b0f49d77dcf52bd812ef1d1e

Issue Description:

Related thread (which I wish got some clarifications from the core team):

As far as I understand, single element tuples should be prevented in Swift.

The following program does not compile with (the default toolchain of) Xcode 9.4, as expected.

BUT with recent versions of the compiler (default toolchains of Xcode 10 beta 1 and beta 2, as well as recent dev snapshots), it does compile.

let t = (label: 123)
print(t.label + t.label) // prints 246

So we can define `t` to be of an instance of a (labeled) single-element tuple type, and use it as such.

But we cannot dump or print or otherwise access its type without getting (nonsensical) errors, and we cannot define its type explicitly, meaning the following will not compile:

let t: (label: Int) = (label: 123)
print(t.label + t.label)


Also, as a side note, the following program compiles with all versions of the compiler (including Xcode 9.4):

let r = (label: 12).label + (label: 34).label
print(r) // prints 46

But I guess it shouldn't?

Copy link

@belkadan belkadan commented Jun 26, 2018

Thanks, Jens.

@swift-ci create

Copy link

@rudkx rudkx commented Jun 27, 2018

I suspect this is a result of my change to eliminate exponential behavior in expression type checking for tuple expressions.

Copy link

@jepers jepers commented Oct 11, 2018

Issue still remains in default toolchain of Xcode 10.
I suppose this related example shouldn't compile either:

let t = (singleElementTupleLabel: 123).singleElementTupleLabel


Copy link

@swift-ci swift-ci commented Nov 18, 2018

Comment by Tim (JIRA)

With the latest master toolchain `let t = (label: 123)` no longer compiles, instead it results in Abort trap: 6.

Copy link

@slavapestov slavapestov commented Dec 16, 2018

Copy link

@AnnaZaks AnnaZaks mannequin commented Jul 23, 2019

@jepers, Could you verify if the problem is fixed and if so move the JIRA to "Closed"?


@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

5 participants