Files
swift-mirror/test/Parse/matching_patterns.swift
Joe Groff 675de63208 Parse matching pattern specific productions at top level.
Parse 'var', '_', and 'is' pattern forms at the top level of a matching pattern context. Keep track of VarPatternDepth in the parser state and raise an error if 'var' appears in a 'var'.

Swift SVN r5839
2013-06-27 18:13:01 +00:00

31 lines
451 B
Swift

// RUN: %swift -dump-parse -verify %s
var x:Int
func square(x:Int) -> Int { return x*x }
struct A<B> {
struct C<D> { }
}
switch x {
// Expressions as patterns.
case 0:
case 1 + 2:
case square(9):
// 'var' pattern.
case var a:
case var var a: // expected-error{{'var' cannot appear nested inside another 'var' pattern}}
// 'Any' pattern.
case _:
// 'is' pattern.
case is A<B>:
case is A<B>.C<D>:
case is (Int, Int):
case is (a:Int, b:Int):
}