Files
swift-mirror/test/StringProcessing/Parse/prefix-slash.swift
Hamish Knight 8d59eb08df [Parse] Ban trailing space for /.../ regex literals
Ban space and tab as the last character of a
`/.../` regex literal, unless escaped with a
backslash. This matches the banning of space and
tab as the first character, and helps avoid breaking
source in even more cases.
2022-06-23 20:38:28 +01:00

24 lines
460 B
Swift

// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex -disable-availability-checking
// REQUIRES: swift_in_compiler
// Test the behavior of prefix '/' with regex literals enabled.
prefix operator /
prefix func / <T> (_ x: T) -> T { x }
enum E {
case e
func foo<T>(_ x: T) {}
}
_ = /E.e
(/E.e).foo(/0)
func foo<T, U>(_ x: T, _ y: U) {}
foo(/E.e, /E.e)
foo((/E.e), /E.e)
foo((/)(E.e), /E.e)
func bar<T>(_ x: T) -> Int { 0 }
_ = bar(/E.e) / 2