rintaro
(Rintaro Ishizaki)
1
Hi all,
I'm fixing #if condition processing in this PR
It resolves these issues:
*A) SR-3663 <Issues · apple/swift-issues · GitHub Precedence of '&&' and
'||' and short-circuit rule of them.*
#if false || true && false print("true")#endif
This used to evaluate to 'true'.
*B) SR-4032 <Issues · apple/swift-issues · GitHub Version check with
binary operator.*
#if swift(>=5.0) && FOO
Some Swift 5 code here
#endif
I believe, this block should not be parsed.
*C) SR-3663 <Issues · apple/swift-issues · GitHub Invalid condition
after short-circuit binary operator.*
#if true || true * This is not <acceptable>!
#endif
This used to be accepted.
*D) SR-4031 <Issues · apple/swift-issues · GitHub Compound name in the
condition*
#if FOO(_:)
#elseif os(foo:)(macOS)
#elseif os(Linux(foo:bar:))
#endif
This used to be accepted.
In the PR, I keep A) and B) behavior in -swift-version 3 mode.
However, as for C) and D), I don't think it's worth to keep them even in
Swift3 mode, because they are obviously wrong.
What do you think? Do we need accept them in Swift3 mode?
codafi
(Robert Widmann)
2
I think the source breakage here, if any in actual codebases, is minor enough that the patch could go through.
~Robert Widmann
···
On Mar 8, 2017, at 2:11 AM, rintaro ishizaki via swift-dev <swift-dev@swift.org> wrote:
Hi all,
I'm fixing if condition processing in this PR
[Parse] Separate compilation condition validation and evaluation by rintaro · Pull Request #7955 · apple/swift · GitHub
It resolves these issues:
A) SR-3663 <Issues · apple/swift-issues · GitHub Precedence of '&&' and '||' and short-circuit rule of them.
if false || true && false
print("true")
#endif
This used to evaluate to 'true'.
B) SR-4032 <Issues · apple/swift-issues · GitHub Version check with binary operator.
if swift(>=5.0) && FOO
Some Swift 5 code here
#endif
I believe, this block should not be parsed.
C) SR-3663 <Issues · apple/swift-issues · GitHub Invalid condition after short-circuit binary operator.
if true || true * This is not <acceptable>!
#endif
This used to be accepted.
D) SR-4031 <Issues · apple/swift-issues · GitHub Compound name in the condition
if FOO(_:)
#elseif os(foo:)(macOS)
#elseif os(Linux(foo:bar:))
#endif
This used to be accepted.
In the PR, I keep A) and B) behavior in -swift-version 3 mode.
However, as for C) and D), I don't think it's worth to keep them even in Swift3 mode, because they are obviously wrong.
What do you think? Do we need accept them in Swift3 mode?
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev