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-294] Strange errors for unary prefix operator with tuple arg #42916

Closed
jepers opened this issue Dec 18, 2015 · 6 comments
Closed

[SR-294] Strange errors for unary prefix operator with tuple arg #42916

jepers opened this issue Dec 18, 2015 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@jepers
Copy link

jepers commented Dec 18, 2015

Previous ID SR-294
Radar rdar://23163575
Original Reporter @jepers
Type Bug
Status Closed
Resolution Done
Environment

OS X 10.11.2, Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 69940d1)

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug
Assignee @AnthonyLatsis
Priority Medium

md5: 98ff25433ff92b7970173819af657d87

Issue Description:

prefix operator §{}
prefix func §(a: (Int, Int)) -> Int { return a.0 + a.1}
let a = (1, 2)
let b = §a // Error '§' is not a prefix unary operator
let c = (§)a // Error Consecutive statements on a line must be separated by ';'
let d = (§)(a) // OK
let e = §(1, 2) // Error '§' is not a prefix unary operator
let f = (§)(1, 2) // Error: Extra argument in call
let g = (§)((1, 2)) // OK
@jepers
Copy link
Author

jepers commented Jul 24, 2016

Same result in Xcode 8 beta 3.

@Dante-Broggi
Copy link
Contributor

In the Xcode 9.4.1 toolchain, it is the same result, with the following exceptions:

  • "Operator should no longer be declared with body"

  • `c` gained a warning: "Expression of type '(Int, Int)' is unused"

  • `f`'s error has changed to "Operator function '§' expects a single parameter of type '(Int, Int)'" with fixit, that works.

@jepers
Copy link
Author

jepers commented Oct 29, 2018

I had forgot about this issue when I stumbled on it again but for postfix operators, wrote this post:
https://forums.swift.org/t/prefix-and-postfix-operators-not-working-for-tuple-types/17466
before I remembered this report.

@swift-ci
Copy link
Collaborator

Comment by Jorge Juan (JIRA)

Same behaviour here: Xcode 10.1, Swift 4.2.1

This bug really needs a resolution.

@AnthonyLatsis
Copy link
Collaborator

Looks like this was fixed recently alongside #19580, see this file. I'll add some more test cases to ensure this doesn't get accidentally broken again and we can then close the issue.

@AnthonyLatsis
Copy link
Collaborator

#20346 The tests.

@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
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

4 participants