swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.55k stars 10.35k forks source link

[SR-9012] operator precedence #51515

Closed swift-ci closed 6 years ago

swift-ci commented 6 years ago
Previous ID SR-9012
Radar None
Original Reporter Luris (JIRA User)
Type Bug
Status Resolved
Resolution Invalid

Attachment: Download

Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 2b0d52050570a3e0e5f794af35132df7

Issue Description:

Using operator precedence in swift, the order of operations is wrong, see the screenshot_01.

Objective-c is correct.see the screenshot_02.

belkadan commented 6 years ago

Swift's operator precedence rules are deliberately differently from C's in a few places, to avoid common mistakes that happen in C. << is one of them.