[SR-294] Strange errors for unary prefix operator with tuple arg
| 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 69940d166c)
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
Same result in Xcode 8 beta 3.
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.
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.
Comment by Jorge Juan (JIRA)
Same behaviour here: Xcode 10.1, Swift 4.2.1
This bug really needs a resolution.
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.
#20346 The tests.