[swift-dev] Breaking change in lexing operators next to comments

Jesse Rusak me at jesserusak.com
Mon Dec 14 22:15:47 CST 2015

Hi all,

Iā€™m investigating this bug: https://bugs.swift.org/browse/SR-186

Which appears to be a result of the fact that the logic that determines if an operator is prefix/postfix/binary does not treat comments as whitespace. So, for example:

/* comment */!foo

does not lex as expected because the ā€œ!" thinks it has an something on both sides and so is treated as a binary operator. 

Fixing this (by treating comments as whitespace here) will break existing code which relies on the current behavior, such as:

foo/* comment */!

which currently treats the ā€œ!ā€ as a postfix operator but will change to binary. I expect these cases would be rare (maybe in some generated code?), but the results might be pretty confusing. 

Any objections to fixing this or other thoughts? 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151214/176a7f92/attachment.html>

More information about the swift-dev mailing list