You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Nov 1, 2016
· 2 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug, Parser
Assignee
None
Priority
Medium
md5: 33e734cec0f42a845b74f772568d3003
Issue Description:
In Swift 3, one can declare a postfix operator that starts with a ? or a !, but as far as I can tell, there's no way to actually use such an operator:
postfixoperator ?**
postfixfunc ?**(x: Int) -> Int { returnx }
letx = 12x?** // error: use of unresolved operator '**'postfixoperator !**
postfixfunc !**(x: Int) -> Int { returnx }
letx = 12x!** // error: use of unresolved operator '**'
The parser interprets the ? and the ! as part of an optional chaining expr or a forced value expr, respectively. Additionally, the Swift Programming Language book states:
"Although you can define custom operators that contain a question mark ?, they can’t consist of a single question mark character only. Additionally, although operators can contain an exclamation mark !, postfix operators cannot begin with either a question mark or an exclamation mark."
Thus, I think the compiler should prohibit the declaration of a postfix operator that starts with a question mark or an exclamation mark.
The text was updated successfully, but these errors were encountered:
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
Environment
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Additional Detail from JIRA
md5: 33e734cec0f42a845b74f772568d3003
Issue Description:
In Swift 3, one can declare a postfix operator that starts with a ? or a !, but as far as I can tell, there's no way to actually use such an operator:
The parser interprets the ? and the ! as part of an optional chaining expr or a forced value expr, respectively. Additionally, the Swift Programming Language book states:
"Although you can define custom operators that contain a question mark ?, they can’t consist of a single question mark character only. Additionally, although operators can contain an exclamation mark !, postfix operators cannot begin with either a question mark or an exclamation mark."
Thus, I think the compiler should prohibit the declaration of a postfix operator that starts with a question mark or an exclamation mark.
The text was updated successfully, but these errors were encountered: