[swift-dev] Breaking change in lexing operators next to comments
clattner at apple.com
Mon Dec 14 23:42:35 CST 2015
> On Dec 14, 2015, at 8:15 PM, Jesse Rusak via swift-dev <swift-dev at swift.org> wrote:
> Hi all,
> I’m investigating this bug: https://bugs.swift.org/browse/SR-186 <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?
There are two defensible models here:
1) comments should be treated as whitespace.
2) comments should be treated as if they were not present.
The later model seems more ideal to me (because you can put whitespace on either side of the comment after all), but I don’t have a strong opinion about that. What do others think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev