Files
swift-mirror/test/stdlib/UnicodeScalarDiagnostics.swift
Dmitri Hrybenko 6e5060d471 stdlib/UnicodeScalar: remove arithmetic operations, they interact in
non-obvious ways with double-quoted literal sytax; "1" - "1" used to compile

rdar://17225816


Swift SVN r19563
2014-07-04 13:11:52 +00:00

28 lines
1.5 KiB
Swift

// RUN: %swift %s -parse -verify
func isString(inout s: String) {}
func test_UnicodeScalarDoesNotImplementArithmetic(us: UnicodeScalar, i: Int) {
var a1 = "a" + "b" // OK
isString(&a1)
let a2 = "a" - "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let a3 = "a" * "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let a4 = "a" / "b" // expected-error {{type 'UInt8' does not conform to protocol 'ExtendedGraphemeClusterLiteralConvertible'}}
let b1 = us + us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b2 = us - us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b3 = us * us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let b4 = us / us // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let c1 = us + i // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let c2 = us - i // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let c3 = us * i // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let c4 = us / i // expected-error {{'UnicodeScalar' is not convertible to 'UInt8'}}
let d1 = i + us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d2 = i - us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d3 = i * us // expected-error {{'Int' is not convertible to 'UInt8'}}
let d4 = i / us // expected-error {{'Int' is not convertible to 'UInt8'}}
}