mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
24 lines
460 B
Swift
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
|