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
Anonymous closure argument not contained in a closure
Cannot convert value of type '((Sample) throws -> Bool) throws -> Bool' to expected condition type 'Bool'
Closure expression is unused
Consecutive statements on a line must be separated by ';'
Expected 'else' after 'guard' condition
For comparison, a trailing closure in an if condition gives:
{{ if samples.contains { $0.isInfinite } { return }}}}}{}}}
{{ ~^}}
{{ (where: )}}
While guard is using the same condition grammar that if uses, which prohibits the trailing closure here, since guard has no then clause the trailing closure is not actually ambiguous, so it either requires a slightly different diagnostic, or a relaxation of the grammar to allow the trailing closure in a guard condition.
The text was updated successfully, but these errors were encountered:
if case is actually not "ambiguous" either.
For 'if something { ... } { ... }', the first block can't be a then block because then blocks can't have a trailing block without `else`, also the second block can't be a trailing closure because multiple trailing closure requires labels. But it's is still confusable. That's why the diagnostic is a warning, and recommends using a parenthesized argument.
guard case is similar. It is not ambiguous, but confusable. So guard case should be diagnosed as a warning just like if.
Environment
Version 13.0 beta 5 (13A5212g)
Additional Detail from JIRA
md5: 668dc78ec042659d0b3a118604c2d487
Issue Description:
guard samples.contains{ $0.isInfinite } else { return }gives
For comparison, a trailing closure in an
ifcondition gives:{{ if samples.contains { $0.isInfinite } { return }}}}}{}}}
{{ ~^}}
{{ (where: )}}
While
guardis using the same condition grammar thatifuses, which prohibits the trailing closure here, sinceguardhas nothenclause the trailing closure is not actually ambiguous, so it either requires a slightly different diagnostic, or a relaxation of the grammar to allow the trailing closure in aguardcondition.The text was updated successfully, but these errors were encountered: