Files
swift-mirror/test/Parse/invalid_if_expr.swift
Joe Groff f026e44c18 Integrate ternary parsing with precedence parsing.
Give the ternary a fixed precedence, parse '?' and ':' into SequenceExprs, and fold them into IfExprs as part of sequence folding. This allows assignment operators like '+=' to have precedence below the ternary as in C. Fixes <rdar://problem/13756211>.

Swift SVN r4983
2013-04-29 22:15:52 +00:00

9 lines
450 B
Swift

// RUN: %swift -parse -verify %s
func unbalanced_question(a:Bool, b:Bool, c:Bool, d:Bool) {
(a ? b) // expected-error{{expected ':' after '? ...' in ternary}}
(a ? b : c ? d) // expected-error{{expected ':' after '? ...' in ternary}}
(a ? b ? c : d) // expected-error{{expected ':' after '? ...' in ternary}}
(a ? b ? c) // expected-error{{expected ':' after '? ...' in ternary}} // expected-error{{expected ':' after '? ...' in ternary}}
}