diff --git a/test/1_stdlib/StringDiagnostics.swift b/test/1_stdlib/StringDiagnostics.swift index 49b60c2ee4483..84adf91640700 100644 --- a/test/1_stdlib/StringDiagnostics.swift +++ b/test/1_stdlib/StringDiagnostics.swift @@ -6,17 +6,17 @@ import Foundation // Common pitfall: trying to subscript a string with integers. func testIntSubscripting(s: String, i: Int) { - let c1 = s[i] // expected-error{{'subscript' is unavailable: cannot subscript String with an Int}} - let c2 = s[17] // expected-error{{'subscript' is unavailable: cannot subscript String with an Int}} - let c3 = s[i...i] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} - let c4 = s[17..<20] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} - let c5 = s[17...20] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} + let _ = s[i] // expected-error{{'subscript' is unavailable: cannot subscript String with an Int}} + let _ = s[17] // expected-error{{'subscript' is unavailable: cannot subscript String with an Int}} + let _ = s[i...i] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} + let _ = s[17..<20] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} + let _ = s[17...20] // expected-error{{subscript' is unavailable: cannot subscript String with a range of Int}} } func testNonAmbiguousStringComparisons() { let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"] - var reversed1 = sorted(names, { s1, s2 in s1 > s2 }) - var reversed2 = sorted(names, { s1, s2 in s1 as String > s2 }) + var _ = sorted(names, { s1, s2 in s1 > s2 }) + var _ = sorted(names, { s1, s2 in s1 as String > s2 }) } func testAmbiguousStringComparisons(s: String) { diff --git a/test/BuildConfigurations/pound-if-inside-function-3.swift b/test/BuildConfigurations/pound-if-inside-function-3.swift index 4927beaf82b53..aa28b9c76040d 100644 --- a/test/BuildConfigurations/pound-if-inside-function-3.swift +++ b/test/BuildConfigurations/pound-if-inside-function-3.swift @@ -5,7 +5,7 @@ func foo() { // expected-note {{to match this opening '{'}} #if BLAH - var x = 123; + var _ = 123; #elseif !BLAH #else // expected-error@+2{{expected '}' at end of brace statement}} diff --git a/test/BuildConfigurations/pound-if-inside-function-4.swift b/test/BuildConfigurations/pound-if-inside-function-4.swift index 241686eb4c204..3eada8cc42acb 100644 --- a/test/BuildConfigurations/pound-if-inside-function-4.swift +++ b/test/BuildConfigurations/pound-if-inside-function-4.swift @@ -5,7 +5,7 @@ func foo() { // expected-note {{to match this opening '{'}} #if BLAH - var x = 123; + var _ = 123; #elseif !BLAH #else #else // expected-error{{further conditions after #else are unreachable}} diff --git a/test/ClangModules/MixedSource/mixed-nsuinteger.swift b/test/ClangModules/MixedSource/mixed-nsuinteger.swift index 93f62d3ca57e7..32bd0d0780cdd 100644 --- a/test/ClangModules/MixedSource/mixed-nsuinteger.swift +++ b/test/ClangModules/MixedSource/mixed-nsuinteger.swift @@ -38,9 +38,9 @@ var rr: UInt = userTypedObj.countByEnumeratingWithState(p, objects: pp, count: u // Check exercising protocol conformance. func gen(t:T) { - var i: Int = 56 - var p: UnsafeMutablePointer = nil - var pp: AutoreleasingUnsafeMutablePointer = nil + let i: Int = 56 + let p: UnsafeMutablePointer = nil + let pp: AutoreleasingUnsafeMutablePointer = nil t.countByEnumeratingWithState(p, objects: pp, count: i) } diff --git a/test/ClangModules/MixedSource/mixed-target-using-header.swift b/test/ClangModules/MixedSource/mixed-target-using-header.swift index 15d4934d87f36..63eb09873e06b 100644 --- a/test/ClangModules/MixedSource/mixed-target-using-header.swift +++ b/test/ClangModules/MixedSource/mixed-target-using-header.swift @@ -54,6 +54,6 @@ func testMacro() { } func testFoundationOverlay() { - let utf8 = NSUTF8StringEncoding // no ambiguity + let _ = NSUTF8StringEncoding // no ambiguity let _: UInt = NSUTF8StringEncoding // and we should get the overlay version } diff --git a/test/ClangModules/MixedSource/mixed-target-using-module.swift b/test/ClangModules/MixedSource/mixed-target-using-module.swift index e0bf12b929d3f..170fc8f7ee399 100644 --- a/test/ClangModules/MixedSource/mixed-target-using-module.swift +++ b/test/ClangModules/MixedSource/mixed-target-using-module.swift @@ -58,9 +58,9 @@ class Derived : Base { } func testMethod(container: Base, input: ForwardClass, inputProto: ForwardProto, inputPartial: PartialSubClass) { - let output: ForwardClass = container.unsafeOverrideReturn(input) // no-warning - let outputProto: ForwardProto = container.unsafeOverrideProtoReturn(inputProto) // no-warning - let outputPartial: PartialSubClass = container.unsafeOverridePartialSubReturn(inputPartial) // no-warning + let _: ForwardClass = container.unsafeOverrideReturn(input) // no-warning + let _: ForwardProto = container.unsafeOverrideProtoReturn(inputProto) // no-warning + let _: PartialSubClass = container.unsafeOverridePartialSubReturn(inputPartial) // no-warning } diff --git a/test/ClangModules/availability.swift b/test/ClangModules/availability.swift index c622a62add905..87aaed9ea2c7b 100644 --- a/test/ClangModules/availability.swift +++ b/test/ClangModules/availability.swift @@ -25,7 +25,7 @@ func test_unavailable_func(x : NSObject) { } func test_deprecated_imported_as_unavailable(s:UnsafeMutablePointer) { - let x = tmpnam(s) // expected-warning {{'tmpnam' is deprecated: Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.}} + let _ = tmpnam(s) // expected-warning {{'tmpnam' is deprecated: Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.}} } func test_NSInvocation(x: NSInvocation, // expected-error {{'NSInvocation' is unavailable}} @@ -40,7 +40,7 @@ func test_class_avail(x:NSObject, obj: AnyObject) { func test_unavailable_app_extension() { // No expected error here. See corresponding App extension test. - let x = SomeCrazyAppExtensionForbiddenAPI() // no-error + let _ = SomeCrazyAppExtensionForbiddenAPI() // no-error } func test_swift_unavailable() { diff --git a/test/ClangModules/availability_app_extension.swift b/test/ClangModules/availability_app_extension.swift index f24b9aab8e8f3..448d599a5ae3a 100644 --- a/test/ClangModules/availability_app_extension.swift +++ b/test/ClangModules/availability_app_extension.swift @@ -5,5 +5,5 @@ import Foundation func test_unavailable_app_extension() { - let x = SomeCrazyAppExtensionForbiddenAPI() // expected-error {{'SomeCrazyAppExtensionForbiddenAPI()' is unavailable: Not available in App Extensions}} + let _ = SomeCrazyAppExtensionForbiddenAPI() // expected-error {{'SomeCrazyAppExtensionForbiddenAPI()' is unavailable: Not available in App Extensions}} } diff --git a/test/ClangModules/availability_macosx.swift b/test/ClangModules/availability_macosx.swift index f476556e90100..deb1dba8741fc 100644 --- a/test/ClangModules/availability_macosx.swift +++ b/test/ClangModules/availability_macosx.swift @@ -6,7 +6,7 @@ import Foundation import AvailabilityExtras func test_unavailable_because_deprecated() { - let x = NSRealMemoryAvailable() // expected-error {{APIs deprecated as of OS X 10.9 and earlier are unavailable in Swift}} + let _ = NSRealMemoryAvailable() // expected-error {{APIs deprecated as of OS X 10.9 and earlier are unavailable in Swift}} } func test_swift_unavailable_wins() { diff --git a/test/ClangModules/blocks_parse.swift b/test/ClangModules/blocks_parse.swift index 3e55b13778d5a..22489b50b0d1c 100644 --- a/test/ClangModules/blocks_parse.swift +++ b/test/ClangModules/blocks_parse.swift @@ -23,5 +23,5 @@ func testNoEscape(@noescape f: @convention(block) () -> Void, nsStr: NSString, // rdar://problem/19818617 nsStr.enumerateLinesUsingBlock(fStr) // okay due to @noescape - var x: Int = nsStr.enumerateLinesUsingBlock // expected-error{{'(@noescape (String!) -> Void) -> Void' is not convertible}} + var _: Int = nsStr.enumerateLinesUsingBlock // expected-error{{'(@noescape (String!) -> Void) -> Void' is not convertible}} } diff --git a/test/ClangModules/cf.swift b/test/ClangModules/cf.swift index fca7fb51a5a11..702030d957566 100644 --- a/test/ClangModules/cf.swift +++ b/test/ClangModules/cf.swift @@ -37,7 +37,7 @@ func test4() { func test5() { let power: Unmanaged = .passUnretained(kCCPowerStandard) assertUnmanaged(power) - let fridge = CCRefrigeratorCreate(power.takeUnretainedValue()) + let _ = CCRefrigeratorCreate(power.takeUnretainedValue()) } func test6() { @@ -51,8 +51,8 @@ func test7() { } func test8(f: CCRefrigerator) { - let v1: CFTypeRef = f - let v2: AnyObject = f + let _: CFTypeRef = f + let _: AnyObject = f } func test9() { @@ -73,17 +73,17 @@ func testProperty(k: Kitchen) { } func testTollFree0(mduct: MutableDuct) { - let ccmduct: CCMutableDuct = mduct + let _: CCMutableDuct = mduct let duct: Duct = mduct - let ccduct: CCDuct = duct + let _: CCDuct = duct } func testTollFree1(ccmduct: CCMutableDuct) { - let mduct: MutableDuct = ccmduct + let _: MutableDuct = ccmduct let ccduct: CCDuct = ccmduct - let duct: Duct = ccduct + let _: Duct = ccduct } func testChainedAliases(fridge: CCRefrigerator) { diff --git a/test/ClangModules/cfuncs_parse.swift b/test/ClangModules/cfuncs_parse.swift index dfe8f4962a761..7aac72e45daec 100644 --- a/test/ClangModules/cfuncs_parse.swift +++ b/test/ClangModules/cfuncs_parse.swift @@ -10,35 +10,35 @@ func test_cfunc1(i: Int) { } func test_cfunc2(i: Int) { - var f = cfunc2(i, 17) - var f2 : Float = f + let f = cfunc2(i, 17) + var _ : Float = f // FIXME: Should report this error: {{cannot convert the expression's type '$T3' to type 'CLong'}} cfunc2(b:17, a:i) // expected-error{{cannot invoke 'cfunc2' with an argument list of type '(b: Int, a: Int)'}} expected-note {{expected an argument list of type '(Int, Int32)'}} } func test_cfunc3_a() { - var b = cfunc3( { (a : Double, b : Double) -> Double in a + b } ) - var d : Double = b(1.5, 2.5) - var d1 : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} + let b = cfunc3( { (a : Double, b : Double) -> Double in a + b } ) + var _ : Double = b(1.5, 2.5) + var _ : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} } func test_cfunc3_b() { - var b = cfunc3( { a, b in a + b } ) - var d : Double = b(1.5, 2.5) - var d1 : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} + let b = cfunc3( { a, b in a + b } ) + var _ : Double = b(1.5, 2.5) + var _ : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} } func test_cfunc3_c() { - var b = cfunc3({ $0 + $1 }) - var d : Double = b(1.5, 2.5) - var d1 : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} + let b = cfunc3({ $0 + $1 }) + var _ : Double = b(1.5, 2.5) + var _ : Double = b // expected-error{{'double_bin_op_block' is not convertible to 'Double'}} } func test_cfunc3_d() { - var x: Double = 0 - var y: Double = 0 - var z: Double? = cfunc3(nil)?(x, y) - var w: Double = cfunc3(nil)!(x, y) + let x: Double = 0 + let y: Double = 0 + var _: Double? = cfunc3(nil)?(x, y) + var _: Double = cfunc3(nil)!(x, y) } func test_cfunc4() { @@ -51,11 +51,11 @@ func test_pow() { } func test_puts(s: String) { - var i = s.withCString { puts($0) + 32 }; + var _ = s.withCString { puts($0) + 32 }; } func test_fopen(filename: String) -> CInt { - var file = filename.withCString { fopen($0, "r") } + let file = filename.withCString { fopen($0, "r") } return file.memory.inode } @@ -103,7 +103,7 @@ func test_pointer() { param_const_void_pointer(fa) // FIXME: param_const_void_pointer([1.0, 2.0, 3.0]) - var op = COpaquePointer() + let op = COpaquePointer() opaque_pointer_param(op) } diff --git a/test/ClangModules/cstring_parse.swift b/test/ClangModules/cstring_parse.swift index 81bf01ea5afe7..db20f7e18aa0a 100644 --- a/test/ClangModules/cstring_parse.swift +++ b/test/ClangModules/cstring_parse.swift @@ -12,5 +12,5 @@ import cfuncs func test_puts(s: String) { - var i = puts(s) + 32 + var _ = puts(s) + 32 } diff --git a/test/ClangModules/ctypes_parse.swift b/test/ClangModules/ctypes_parse.swift index a8dcf985fd233..7e02c57dc6898 100644 --- a/test/ClangModules/ctypes_parse.swift +++ b/test/ClangModules/ctypes_parse.swift @@ -29,9 +29,9 @@ func testAnonEnum() { var a = AnonConst1 a = AnonConst2 #if arch(i386) || arch(arm) - var a2: CUnsignedLongLong = a + var _: CUnsignedLongLong = a #elseif arch(x86_64) || arch(arm64) - var a2: CUnsignedLong = a + var _: CUnsignedLong = a #else __portMe() #endif @@ -40,7 +40,7 @@ func testAnonEnum() { func testAnonEnumSmall() { var a = AnonConstSmall1 a = AnonConstSmall2 - var a2: Int = a + var _: Int = a } func testPoint() -> Float { @@ -57,14 +57,14 @@ func testAnonStructs() { } func testBitfieldMembers() { - var a: StructWithBitfields + var _: StructWithBitfields // TODO: Expose the bitfields as properties. } // FIXME: Import arrays as real array-looking things. func testArrays() { - var fes: NSFastEnumerationState + let fes: NSFastEnumerationState var ulong: CUnsignedLong var pulong: UnsafeMutablePointer @@ -75,14 +75,15 @@ func testArrays() { ulong = fes.extra.2 ulong = fes.extra.3 ulong = fes.extra.4 + _ = ulong; _ = pulong } // FIXME: Import pointers to opaque types as unique types. func testPointers() { - var hWnd: HWND = nil - var cfstr: CFString? = nil - var cfty: CFTypeRef? = cfstr + var _: HWND = nil + let cfstr: CFString? = nil + var _: CFTypeRef? = cfstr } // Ensure that imported structs can be extended, even if typedef'ed on the C @@ -123,11 +124,13 @@ extension CGRect { } func testFuncStructDisambiguation() { - var a : funcOrStruct + let a : funcOrStruct var i = funcOrStruct() i = 5 + _ = i var a2 = funcOrStruct(i: 5) a2 = a + _ = a2 } func testVoid() { @@ -159,31 +162,35 @@ func testImportStdintTypes() { var t10_unqual : UInt = uintptr_t_test t9_unqual = word t10_unqual = uword + _ = t9_unqual + _ = t10_unqual var t9_qual : intptr_t = 0 // no-warning var t10_qual : uintptr_t = 0 // no-warning t9_qual = word t10_qual = uword + _ = t9_qual + _ = t10_qual } func testImportStddefTypes() { - var t1_unqual: Int = ptrdiff_t_test - var t2_unqual: Int = size_t_test - var t3_unqual: Int = rsize_t_test + let t1_unqual: Int = ptrdiff_t_test + let t2_unqual: Int = size_t_test + let t3_unqual: Int = rsize_t_test - var t1_qual: ctypes.ptrdiff_t = t1_unqual - var t2_qual: ctypes.size_t = t2_unqual - var t3_qual: ctypes.rsize_t = t3_unqual + let _: ctypes.ptrdiff_t = t1_unqual + let _: ctypes.size_t = t2_unqual + var _: ctypes.rsize_t = t3_unqual } func testImportSysTypesTypes() { - var t1_unqual: Int = ssize_t_test - var t1_qual: ctypes.ssize_t = t1_unqual + let t1_unqual: Int = ssize_t_test + var _: ctypes.ssize_t = t1_unqual } func testImportCFTypes() { - var t1_unqual: Int = CFIndex_test - var t1_qual: CoreFoundation.CFIndex = t1_unqual + let t1_unqual: Int = CFIndex_test + var _: CoreFoundation.CFIndex = t1_unqual } func testImportOSTypesTypes() { @@ -238,10 +245,10 @@ func testFunctionPointers() { let fp = getFunctionPointer() useFunctionPointer(fp) - let explicitFP: @convention(c) (CInt) -> CInt = fp + let _: @convention(c) (CInt) -> CInt = fp let wrapper: FunctionPointerWrapper = FunctionPointerWrapper(a: nil, b: nil) - let wrapper2 = FunctionPointerWrapper(a: fp, b: fp) + let _ = FunctionPointerWrapper(a: fp, b: fp) useFunctionPointer(wrapper.a) let _: @convention(c) (CInt) -> CInt = wrapper.b diff --git a/test/ClangModules/ctypes_parse_union.swift b/test/ClangModules/ctypes_parse_union.swift index b3632a6979f32..635e5842a4b79 100644 --- a/test/ClangModules/ctypes_parse_union.swift +++ b/test/ClangModules/ctypes_parse_union.swift @@ -48,8 +48,8 @@ func useStructWithBitfields(mrm: ModRM) -> ModRM { // Incompletely imported structs shouldn't have elementwise initializers. // They can still be zero-initialized using the default initializer. func constructStructWithBitfields(x: CUnsignedInt) { - let a: StructWithBitfields = StructWithBitfields() - let b: StructWithBitfields = StructWithBitfields(First: x) // expected-error{{}} + let _: StructWithBitfields = StructWithBitfields() + let _: StructWithBitfields = StructWithBitfields(First: x) // expected-error{{}} // TODO: Fully import bitfields. - let c: StructWithBitfields = StructWithBitfields(First: x, Second: x, Third: x) // expected-error{{}} + let _: StructWithBitfields = StructWithBitfields(First: x, Second: x, Third: x) // expected-error{{}} } diff --git a/test/ClangModules/macros.swift b/test/ClangModules/macros.swift index 60cdcf9d020c0..e828be50ce2dd 100644 --- a/test/ClangModules/macros.swift +++ b/test/ClangModules/macros.swift @@ -63,6 +63,7 @@ func testTrueFalse() { func testCStrings() -> Bool { var str: String = UTF8_STRING str = VERSION_STRING + _ = str } func testObjCString() -> Int { @@ -104,8 +105,8 @@ func testNil() { } func testBitwiseOps() { - let maxUnsigned: CUnsignedLongLong = DISPATCH_TIME_FOREVER - let mask: CInt = BIT_SHIFT_1 | BIT_SHIFT_2 + let _: CUnsignedLongLong = DISPATCH_TIME_FOREVER + let _: CInt = BIT_SHIFT_1 | BIT_SHIFT_2 let _: CLongLong = BIT_SHIFT_3 let _: CUnsignedInt = BIT_SHIFT_4 } diff --git a/test/ClangModules/objc_bridge_categories.swift b/test/ClangModules/objc_bridge_categories.swift index 7ca2ec3b2eff2..3119451ac12b9 100644 --- a/test/ClangModules/objc_bridge_categories.swift +++ b/test/ClangModules/objc_bridge_categories.swift @@ -34,4 +34,5 @@ func testDictionaryBridge(dict: Dictionary) { func testStringBridge() { var i = String.someFactoryMethod() i = 17 + _ = i } diff --git a/test/ClangModules/objc_bridging.swift b/test/ClangModules/objc_bridging.swift index 2e8adffae3d0f..c42b37d21f900 100644 --- a/test/ClangModules/objc_bridging.swift +++ b/test/ClangModules/objc_bridging.swift @@ -26,20 +26,20 @@ extension Set { } func foo() { - var sf : (String!) -> String? = NSStringToNSString - var s : String = NSArray().nsstringProperty.onlyOnString() + var _ : (String!) -> String? = NSStringToNSString + var _ : String = NSArray().nsstringProperty.onlyOnString() - var bf : (Bool) -> Bool = BOOLtoBOOL - var b : Bool = NSArray().boolProperty.onlyOnBool() + var _ : (Bool) -> Bool = BOOLtoBOOL + var _ : Bool = NSArray().boolProperty.onlyOnBool() - var af: (Array!) -> (Array!) = arrayToArray + var _: (Array!) -> (Array!) = arrayToArray NSArray().arrayProperty.onlyOnArray() - var df: (Dictionary!) -> Dictionary! + var _: (Dictionary!) -> Dictionary! = dictToDict NSArray().dictProperty.onlyOnDictionary() - var setf : (Set!) -> Set! = setToSet + var _ : (Set!) -> Set! = setToSet NSArray().setProperty.onlyOnSet() } @@ -57,5 +57,5 @@ func mutablePointerToObjC(path: String) throws -> NSString { func objcStructs(s: StructOfNSStrings) { // Struct fields must not be bridged. - let x: NSString = s.nsstr! + let _: NSString = s.nsstr! } diff --git a/test/ClangModules/objc_bridging_generics.swift b/test/ClangModules/objc_bridging_generics.swift index 681fdf3b52df8..6aac86ddf9098 100644 --- a/test/ClangModules/objc_bridging_generics.swift +++ b/test/ClangModules/objc_bridging_generics.swift @@ -5,19 +5,19 @@ import Foundation func testNSArrayBridging(hive: Hive) { - let bees: [Bee] = hive.bees + let _: [Bee] = hive.bees } func testNSDictionaryBridging(hive: Hive) { - let beesByName: [String : Bee] = hive.beesByName // expected-error{{value of optional type '[String : Bee]?' not unwrapped;}} + let _: [String : Bee] = hive.beesByName // expected-error{{value of optional type '[String : Bee]?' not unwrapped;}} var dict1 = hive.anythingToBees - var dict2: [NSObject : Bee] = dict1 + let dict2: [NSObject : Bee] = dict1 dict1 = dict2 } func testNSSetBridging(hive: Hive) { - let relatedHives: Set= hive.allBees + let _: Set= hive.allBees } public func expectType(_: T.Type, inout _ x: T) {} diff --git a/test/ClangModules/objc_factory_method.swift b/test/ClangModules/objc_factory_method.swift index 70799e8245f41..52a03c92b351f 100644 --- a/test/ClangModules/objc_factory_method.swift +++ b/test/ClangModules/objc_factory_method.swift @@ -6,36 +6,36 @@ import AppKit import NotificationCenter func testInstanceTypeFactoryMethod(queen: B) { - var hive1 = Hive(queen: queen) + var _ = Hive(queen: queen) - var of1 = NSObjectFactory() // okay, prefers init method - var of2 = NSObjectFactory(integer: 1) - var of3 = NSObjectFactory(double: 314159) - var of4 = NSObjectFactory(float: 314159) + var _ = NSObjectFactory() // okay, prefers init method + var _ = NSObjectFactory(integer: 1) + var _ = NSObjectFactory(double: 314159) + var _ = NSObjectFactory(float: 314159) } func testInstanceTypeFactoryMethodInherited() { - var of1 = NSObjectFactorySub() // okay, prefers init method - var of2 = NSObjectFactorySub(integer: 1) - var of3 = NSObjectFactorySub(double: 314159) - var of4 = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}} - var of5 = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{cannot find an initializer for type 'NSObjectFactorySub' that accepts an argument list of type '(buildingWidgets: ())'}} + var _ = NSObjectFactorySub() // okay, prefers init method + var _ = NSObjectFactorySub(integer: 1) + var _ = NSObjectFactorySub(double: 314159) + var _ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}} + var _ = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{cannot find an initializer for type 'NSObjectFactorySub' that accepts an argument list of type '(buildingWidgets: ())'}} } func testNSErrorFactoryMethod(path: String) throws { - var s1 = try NSString(contentsOfFile: path) + var _ = try NSString(contentsOfFile: path) } func testNonInstanceTypeFactoryMethod(s: String) { - var of1 = NSObjectFactory(string: s) // expected-error{{extra argument 'string' in call}} + var _ = NSObjectFactory(string: s) // expected-error{{extra argument 'string' in call}} } func testUseOfFactoryMethod(queen: B) { - var of1 = Hive.hiveWithQueen(queen) // expected-error{{'hiveWithQueen' is unavailable: use object construction 'Hive(queen:)'}} + var _ = Hive.hiveWithQueen(queen) // expected-error{{'hiveWithQueen' is unavailable: use object construction 'Hive(queen:)'}} } func testNonsplittableFactoryMethod() { - var of5 = NSObjectFactory.factoryBuildingWidgets() + var _ = NSObjectFactory.factoryBuildingWidgets() } func testFactoryMethodBlacklist() { @@ -44,7 +44,7 @@ func testFactoryMethodBlacklist() { } func test17261609() { - let num1 = NSDecimalNumber(mantissa:1, exponent:1, isNegative:true) + let _ = NSDecimalNumber(mantissa:1, exponent:1, isNegative:true) NSDecimalNumber.decimalNumberWithMantissa(1, exponent:1, isNegative:true) // expected-error{{'decimalNumberWithMantissa(_:exponent:isNegative:)' is unavailable: use object construction 'NSDecimalNumber(mantissa:exponent:isNegative:)'}} } diff --git a/test/ClangModules/objc_failable_inits.swift b/test/ClangModules/objc_failable_inits.swift index cc5308dbf1e16..12a8fd3122021 100644 --- a/test/ClangModules/objc_failable_inits.swift +++ b/test/ClangModules/objc_failable_inits.swift @@ -12,17 +12,17 @@ func testDictionary() { func testString() throws { // Optional - var stringOpt = NSString(path: "blah", encoding: 0) - var nsStr: NSString = stringOpt // expected-error{{value of optional type 'NSString?' not unwrapped; did you mean to use '!' or '?'?}} + let stringOpt = NSString(path: "blah", encoding: 0) + let _: NSString = stringOpt // expected-error{{value of optional type 'NSString?' not unwrapped; did you mean to use '!' or '?'?}} // Implicitly unwrapped optional - var stringIUO = NSString(path: "blah") + let stringIUO = NSString(path: "blah") if stringIUO == nil { } - var nsStr2: NSString = stringIUO + var _: NSString = stringIUO } func testHive() { - var hiveIUO = Hive() + let hiveIUO = Hive() if hiveIUO == nil { } - var hive: Hive = hiveIUO + var _: Hive = hiveIUO } diff --git a/test/ClangModules/objc_implicit_properties.swift b/test/ClangModules/objc_implicit_properties.swift index 75644ac7c35b0..04ebe7641267a 100644 --- a/test/ClangModules/objc_implicit_properties.swift +++ b/test/ClangModules/objc_implicit_properties.swift @@ -61,8 +61,8 @@ func doSomethingBase(obj: T) {} func doSomethingSub(obj: T) {} func protocols(obj: Sub) { - let baseProto: PropertiesProto = obj - let subProto: SubProto = obj + let _: PropertiesProto = obj + let _: SubProto = obj doSomethingBase(obj) doSomethingSub(obj) } diff --git a/test/ClangModules/objc_implicit_with.swift b/test/ClangModules/objc_implicit_with.swift index 33e55518d4106..b96c1621937e3 100644 --- a/test/ClangModules/objc_implicit_with.swift +++ b/test/ClangModules/objc_implicit_with.swift @@ -17,45 +17,45 @@ class X { func testInitWith(url: String) { - var doc = NSDocument(URL: url) + var _ = NSDocument(URL: url) } func testInstanceTypeFactoryMethod(queen: B) { - var hive1 = Hive(queen: queen) + var _ = Hive(queen: queen) - var of1 = NSObjectFactory() // okay, prefers init method - var of2 = NSObjectFactory(integer: 1) - var of3 = NSObjectFactory(double: 314159) - var of4 = NSObjectFactory(float: 314159) + var _ = NSObjectFactory() // okay, prefers init method + var _ = NSObjectFactory(integer: 1) + var _ = NSObjectFactory(double: 314159) + var _ = NSObjectFactory(float: 314159) } func testInstanceTypeFactoryMethodInherited() { - var of1 = NSObjectFactorySub() // okay, prefers init method - var of2 = NSObjectFactorySub(integer: 1) - var of3 = NSObjectFactorySub(double: 314159) + var _ = NSObjectFactorySub() // okay, prefers init method + var _ = NSObjectFactorySub(integer: 1) + var _ = NSObjectFactorySub(double: 314159) // FIXME: Awful diagnostic - var of4 = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}} - var of5 = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{cannot find an initializer for type 'NSObjectFactorySub' that accepts an argument list of type '(buildingWidgets: ())'}} + var _ = NSObjectFactorySub(float: 314159) // expected-error{{incorrect argument label in call (have 'float:', expected 'integer:')}} + var _ = NSObjectFactorySub(buildingWidgets: ()) // expected-error{{cannot find an initializer for type 'NSObjectFactorySub' that accepts an argument list of type '(buildingWidgets: ())'}} } func testNSErrorFactoryMethod(path: String) throws { - var s1 = try NSString(contentsOfFile: path) + var _ = try NSString(contentsOfFile: path) } func testNonInstanceTypeFactoryMethod(s: String) { - var of1 = NSObjectFactory(string: s) // expected-error{{extra argument 'string' in call}} + var _ = NSObjectFactory(string: s) // expected-error{{extra argument 'string' in call}} } func testUseOfFactoryMethod(queen: B) { - var of1 = Hive.hiveWithQueen(queen) // expected-error{{'hiveWithQueen' is unavailable: use object construction 'Hive(queen:)'}} + var _ = Hive.hiveWithQueen(queen) // expected-error{{'hiveWithQueen' is unavailable: use object construction 'Hive(queen:)'}} } func testNonsplittableFactoryMethod() { - var of5 = NSObjectFactory.factoryBuildingWidgets() + var _ = NSObjectFactory.factoryBuildingWidgets() } // rdar://problem/18797808 func testFactoryMethodWithKeywordArgument() { - var prot = NSCoding.self - var obj = NSXPCInterface(withProtocol: prot) // not "protocol:" + let prot = NSCoding.self + var _ = NSXPCInterface(withProtocol: prot) // not "protocol:" } diff --git a/test/ClangModules/objc_init.swift b/test/ClangModules/objc_init.swift index 5f21cb33abd61..759d77dce5ed2 100644 --- a/test/ClangModules/objc_init.swift +++ b/test/ClangModules/objc_init.swift @@ -42,6 +42,7 @@ func createMyDocument1() { // Inherited convenience init. md = MyDocument1(string: "http://llvm.org") + _ = md } class MyDocument2 : NSDocument { @@ -59,6 +60,7 @@ class MyDocument3 : NSAwesomeDocument { func createMyDocument3() { var md = MyDocument3() md = MyDocument3(URL: "http://llvm.org") + _ = md } class MyInterestingDesignated : NSInterestingDesignatedSub { @@ -72,7 +74,7 @@ class MyInterestingDesignated : NSInterestingDesignatedSub { } func createMyInterestingDesignated() { - var md = MyInterestingDesignated(URL: "http://llvm.org") + var _ = MyInterestingDesignated(URL: "http://llvm.org") } func testNoReturn(a : NSAwesomeDocument) -> Int { @@ -124,7 +126,7 @@ func checkInitWithCoder(coder: NSCoder) { class MyDictionary1 : NSDictionary {} func getMyDictionary1() { - var nsd = MyDictionary1() + _ = MyDictionary1() } // @@ -141,14 +143,14 @@ class MyString : NSString { // class View: NSView { override func addSubview(aView: NSView) { - var p = MyViewController.init() + _ = MyViewController.init() } } // rdar://problem/19726164 class NonNullDefaultInitSubSub : NonNullDefaultInitSub { func foo() { - var x: NonNullDefaultInitSubSub? = NonNullDefaultInitSubSub() + var _: NonNullDefaultInitSubSub? = NonNullDefaultInitSubSub() } } diff --git a/test/ClangModules/objc_parse.swift b/test/ClangModules/objc_parse.swift index 692703a9e093e..08ab6e7899834 100644 --- a/test/ClangModules/objc_parse.swift +++ b/test/ClangModules/objc_parse.swift @@ -14,12 +14,12 @@ import ObjCParseExtrasToo func markUsed(t: T) {} func testAnyObject(obj: AnyObject) { - var optStr = obj.nsstringProperty + var _ = obj.nsstringProperty } // Construction func construction() { - var b = B() + var _ = B() } // Subtyping @@ -160,7 +160,7 @@ func newConstruction(a: A, aproxy: AProxy) { // Indexed subscripting func indexedSubscripting(b: B, idx: Int, a: A) { b[idx] = a - var a2 = b[idx] as! A + var _ = b[idx] as! A } // Keyed subscripting @@ -178,7 +178,7 @@ func keyedSubscripting(b: B, idx: A, a: A) { // Typed indexed subscripting func checkHive(hive: Hive, b: B) { - var b2 = hive.bees[5] as! B + let b2 = hive.bees[5] as! B b2.method(1, withFloat:1.5) } @@ -230,7 +230,7 @@ func getDescription(array: NSArray) { // Method overriding with unfortunate ordering. func overridingTest(srs: SuperRefsSub) { - var rs : RefedSub + let rs : RefedSub rs.overridden() } @@ -242,7 +242,7 @@ func almostSubscriptableValueMismatch(as1: AlmostSubscriptable, a: A) { func almostSubscriptableKeyMismatch(bc: BadCollection, key: NSString) { // FIXME: We end up importing this as read-only due to the mismatch between // getter/setter element types. - var v : AnyObject = bc[key] + var _ : AnyObject = bc[key] } func almostSubscriptableKeyMismatchInherited(bc: BadCollectionChild, @@ -278,7 +278,7 @@ func optionalMemberAccess(w: NSWobbling) { } func protocolInheritance(s: NSString) { - var coding: NSCoding = s + var _: NSCoding = s } func ivars(hive: Hive) { @@ -360,8 +360,8 @@ class ProtocolAdopterBad3 : FooProto { // expected-error{{type 'ProtocolAdopterB func testPreferClassMethodToCurriedInstanceMethod(obj: NSObject) { // FIXME: We shouldn't need the ": Bool" type annotation here. // - let result: Bool = NSObject.isEqual(obj) - let curried = NSObject.isEqual(obj) as (NSObject!) -> Bool // no-warning + let _: Bool = NSObject.isEqual(obj) + let _ = NSObject.isEqual(obj) as (NSObject!) -> Bool // no-warning } @@ -375,6 +375,7 @@ func testPropertyAndMethodCollision(obj: PropertyAndMethodCollision, var value: AnyObject = obj.protoProp() value = obj.protoPropRO() + _ = value } func testSubscriptAndPropertyRedeclaration(obj: SubscriptAndProperty) { @@ -478,6 +479,6 @@ class ProtoAdopter : NSObject, ExplicitSetterProto, OptionalSetterProto { } func testUnusedResults(ur: UnusedResults) { - let x = ur.producesResult() + let _ = ur.producesResult() ur.producesResult() // expected-warning{{result of call to 'producesResult()' is unused}} } diff --git a/test/ClangModules/objc_proxies.swift b/test/ClangModules/objc_proxies.swift index fb7434f4baedb..16b9e9ac12326 100644 --- a/test/ClangModules/objc_proxies.swift +++ b/test/ClangModules/objc_proxies.swift @@ -8,6 +8,6 @@ func testAnimatorProxy(constraint:NSLayoutConstraint) { // Rely on warning on 'AnyObject' as an inferred type to check // if the result of 'animator' is being treated as instancetype. let x = constraint.animator() - let y = x.constant + let _ = x.constant } diff --git a/test/Constraints/array_literal.swift b/test/Constraints/array_literal.swift index e4aad21bf2629..33f3918e733f5 100644 --- a/test/Constraints/array_literal.swift +++ b/test/Constraints/array_literal.swift @@ -89,13 +89,13 @@ var x3 = [1, 2, 3] x3[0] = 4 func trailingComma() { - var a1 = [1, ] - var a2 = [1, 2, ] - var d1 = ["a": 1, ] - var d2 = ["a": 1, "b": 2, ] + var _ = [1, ] + var _ = [1, 2, ] + var _ = ["a": 1, ] + var _ = ["a": 1, "b": 2, ] } func longArray() { - var words=["1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"] + var _=["1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"] } diff --git a/test/Constraints/bridging.swift b/test/Constraints/bridging.swift index 6404a80672cd7..193c50bda922d 100644 --- a/test/Constraints/bridging.swift +++ b/test/Constraints/bridging.swift @@ -89,6 +89,7 @@ func arrayToNSArray() { nsa = [OtherClass]() as NSArray nsa = [BridgedStruct]() as NSArray nsa = [NotBridgedStruct]() as NSArray // expected-error{{'[NotBridgedStruct]' is not convertible to 'NSArray'}} + _ = nsa } // NSArray -> Array diff --git a/test/Constraints/casts.swift b/test/Constraints/casts.swift index 23631b9a73f27..b97401105a349 100644 --- a/test/Constraints/casts.swift +++ b/test/Constraints/casts.swift @@ -28,19 +28,19 @@ var b_is_d:Bool = B() is D var bad_d_is_b:Bool = D() is B // expected-warning{{always true}} func base_class_archetype_casts(t: T) { - var t_as_b : B = t - var b_as_t = B() as! T - var bad_b_as_t : T = B() // expected-error{{}} + var _ : B = t + var _ = B() as! T + var _ : T = B() // expected-error{{}} - var b = B() + let b = B() - var b_as_t_2 = b as! T + var _ = b as! T - var b_is_t:Bool = B() is T - var b_is_t_2:Bool = b is T - var bad_t_is_b:Bool = t is B // expected-warning{{always true}} + var _:Bool = B() is T + var _:Bool = b is T + var _:Bool = t is B // expected-warning{{always true}} - var t_as_d = t as! D + var _ = t as! D } protocol P1 { func p1() } @@ -67,71 +67,71 @@ struct S12 : P1, P2 { func protocol_archetype_casts(t: T, p1: P1, p2: P2, p12: protocol) { // Coercions. - var t_as_p1 : P1 = t - var t_as_p2 : P2 = t // expected-error{{}} + var _ : P1 = t + var _ : P2 = t // expected-error{{}} // Checked unconditional casts. - var p1_as_t = p1 as! T - var p2_as_t = p2 as! T - var p12_as_t = p12 as! T + var _ = p1 as! T + var _ = p2 as! T + var _ = p12 as! T - var t_as_s1 = t as! S1 - var t_as_s12 = t as! S12 - var t_as_c1 = t as! C1 - var t_as_d1 = t as! D1 + var _ = t as! S1 + var _ = t as! S12 + var _ = t as! C1 + var _ = t as! D1 - var t_as_s2 = t as! S2 + var _ = t as! S2 - var s1_as_t = S1() as! T - var s12_as_t = S12() as! T - var c1_as_t = C1() as! T - var d1_as_t = D1() as! T + var _ = S1() as! T + var _ = S12() as! T + var _ = C1() as! T + var _ = D1() as! T - var s2_as_t = S2() as! T + var _ = S2() as! T // Type queries. - var p1_is_t:Bool = p1 is T - var p2_is_t:Bool = p2 is T - var p12_is_t:Bool = p12 is T + var _:Bool = p1 is T + var _:Bool = p2 is T + var _:Bool = p12 is T - var t_is_s1:Bool = t is S1 - var t_is_s12:Bool = t is S12 - var t_is_c1:Bool = t is C1 - var t_is_d1:Bool = t is D1 + var _:Bool = t is S1 + var _:Bool = t is S12 + var _:Bool = t is C1 + var _:Bool = t is D1 - var t_is_s2:Bool = t is S2 + var _:Bool = t is S2 } func protocol_concrete_casts(p1: P1, p2: P2, p12: protocol) { // Checked unconditional casts. - var p1_as_s1 = p1 as! S1 - var p1_as_c1 = p1 as! C1 - var p1_as_d1 = p1 as! D1 - var p1_as_s12 = p1 as! S12 + var _ = p1 as! S1 + var _ = p1 as! C1 + var _ = p1 as! D1 + var _ = p1 as! S12 - var p1_as_p12 = p1 as! protocol + var _ = p1 as! protocol - var p2_as_s1 = p2 as! S1 + var _ = p2 as! S1 - var p12_as_s1 = p12 as! S1 - var p12_as_s2 = p12 as! S2 - var p12_as_s12 = p12 as! S12 - var p12_as_s3 = p12 as! S3 + var _ = p12 as! S1 + var _ = p12 as! S2 + var _ = p12 as! S12 + var _ = p12 as! S3 // Type queries. - var p1_is_s1:Bool = p1 is S1 - var p1_is_c1:Bool = p1 is C1 - var p1_is_d1:Bool = p1 is D1 - var p1_is_s12:Bool = p1 is S12 + var _:Bool = p1 is S1 + var _:Bool = p1 is C1 + var _:Bool = p1 is D1 + var _:Bool = p1 is S12 - var p1_is_p12:Bool = p1 is protocol + var _:Bool = p1 is protocol - var p2_is_s1:Bool = p2 is S1 + var _:Bool = p2 is S1 - var p12_is_s1:Bool = p12 is S1 - var p12_is_s2:Bool = p12 is S2 - var p12_is_s12:Bool = p12 is S12 - var p12_is_s3:Bool = p12 is S3 + var _:Bool = p12 is S1 + var _:Bool = p12 is S2 + var _:Bool = p12 is S12 + var _:Bool = p12 is S3 } func conditional_cast(b: B) -> D? { @@ -146,24 +146,24 @@ protocol NonObjCProto : class {} class NonObjCClass {} func objc_protocol_casts(op1: ObjCProto1, opn: NonObjCProto) { - var p1 = ObjCClass() as! ObjCProto1 - var p2 = ObjCClass() as! ObjCProto2 - var p12 = ObjCClass() as! protocol - var pn = ObjCClass() as! NonObjCProto - var p1n = ObjCClass() as! protocol - - var op12 = op1 as! protocol - var op2 = op1 as! protocol - var op1n = op1 as! protocol - var opn1 = opn as! ObjCProto1 - - var np1 = NonObjCClass() as! ObjCProto1 + var _ = ObjCClass() as! ObjCProto1 + var _ = ObjCClass() as! ObjCProto2 + var _ = ObjCClass() as! protocol + var _ = ObjCClass() as! NonObjCProto + var _ = ObjCClass() as! protocol + + var _ = op1 as! protocol + var _ = op1 as! protocol + var _ = op1 as! protocol + var _ = opn as! ObjCProto1 + + var _ = NonObjCClass() as! ObjCProto1 } func dynamic_lookup_cast(dl: AnyObject) { - var p1 = dl as! ObjCProto1 - var p2 = dl as! ObjCProto2 - var p12 = dl as! protocol + var _ = dl as! ObjCProto1 + var _ = dl as! ObjCProto2 + var _ = dl as! protocol } // Cast to subclass with generic parameter inference @@ -184,11 +184,11 @@ var f: Float -> Float = { $0 as Float } var f2: B -> Bool = { $0 is D } func metatype_casts(b: B.Type, t:T.Type, u: U.Type) { - let x1 = b is D.Type - let x2 = T.self is U.Type - let x3 = T.self.dynamicType is U.Type.Type - let x4 = b.dynamicType is D.Type // expected-warning{{always fails}} - let x5 = b is D.Type.Type // expected-warning{{always fails}} + let _ = b is D.Type + let _ = T.self is U.Type + let _ = T.self.dynamicType is U.Type.Type + let _ = b.dynamicType is D.Type // expected-warning{{always fails}} + let _ = b is D.Type.Type // expected-warning{{always fails}} } @@ -201,5 +201,6 @@ func forcedDowncastToOptional(b: B) { // expected-note@-1{{use 'as?' to perform a conditional downcast to 'D'}}{{14-15=?}} // expected-note@-2{{add parentheses around the cast to silence this warning}}{{10-10=(}}{{17-17=)}} dOpt = (b as! D) + _ = dOpt } diff --git a/test/Constraints/closures.swift b/test/Constraints/closures.swift index 4eb70d643435d..d52109c15b651 100644 --- a/test/Constraints/closures.swift +++ b/test/Constraints/closures.swift @@ -49,13 +49,14 @@ struct X3 { } func testX3(var x: Int) { - var q = X3({ x = $0 }) + var _ = X3({ x = $0 }) } // func test13811882() { - var f : (Int) -> (Int, Int) = {($0, $0)} + var _ : (Int) -> (Int, Int) = {($0, $0)} var x = 1 - var g : (Int) -> (Int, Int) = {($0, x)} + var _ : (Int) -> (Int, Int) = {($0, x)} + x = 2 } diff --git a/test/Constraints/default_literals.swift b/test/Constraints/default_literals.swift index 73a485d4af966..c78f7a585eb08 100644 --- a/test/Constraints/default_literals.swift +++ b/test/Constraints/default_literals.swift @@ -20,7 +20,7 @@ ternary(false, 1, 2 as Int32) ternary(false, 1, 2 as Float) func genericFloatingLiteral(x: T) { - var x2 : T = 2.5 + var _ : T = 2.5 } var d = 3.5 diff --git a/test/Constraints/fixes.swift b/test/Constraints/fixes.swift index d0f7fe94d2e6b..cc9b31c7bacba 100644 --- a/test/Constraints/fixes.swift +++ b/test/Constraints/fixes.swift @@ -63,6 +63,7 @@ func forgotOptionalBang(a: A, obj: AnyObject) { func forgotAnyObjectBang(obj: AnyObject) { var a = A() a = obj // expected-error{{'AnyObject' is not convertible to 'A'; did you mean to use 'as!' to force downcast?}}{{10-10= as! A}} + _ = a } func increment(inout x: Int) { } diff --git a/test/Constraints/keyword_arguments.swift b/test/Constraints/keyword_arguments.swift index 3b1040eab5b4c..7ca4cdabc9be1 100644 --- a/test/Constraints/keyword_arguments.swift +++ b/test/Constraints/keyword_arguments.swift @@ -237,7 +237,7 @@ trailingclosure1(x: 1, { return 5 }) // expected-error{{missing argument label ' func trailingclosure2(x x: Int, f: (() -> Int)!...) {} trailingclosure2(x: 5) { return 5 } -func trailingclosure3(x x: Int, var f: (() -> Int)!) {} +func trailingclosure3(x x: Int, var f: (() -> Int)!) { f = nil} trailingclosure3(x: 5) { return 5 } func trailingclosure4(f f: () -> Int) {} diff --git a/test/Constraints/members.swift b/test/Constraints/members.swift index dec424cc5a96b..882d124a3251e 100644 --- a/test/Constraints/members.swift +++ b/test/Constraints/members.swift @@ -131,14 +131,14 @@ protocol P2 { func generic(t: T) { - var bar = t.bar // expected-error{{partial application of generic method is not allowed}} - var barFull : () = t.bar(0) + var _ = t.bar // expected-error{{partial application of generic method is not allowed}} + var _ : () = t.bar(0) } func existential(p: P, p2 : P2) { - var bar = p.bar // expected-error{{partial application of protocol method is not allowed}} - var bar2 = p2.bar // expected-error{{partial application of protocol method is not allowed}} - var barFull : () = p.bar(0) + var _ = p.bar // expected-error{{partial application of protocol method is not allowed}} + var _ = p2.bar // expected-error{{partial application of protocol method is not allowed}} + var _ : () = p.bar(0) } protocol ClassP : class { @@ -146,13 +146,13 @@ protocol ClassP : class { } func genericClassP(t: T) { - var bas = t.bas - var barFull : () = t.bas(0) + var _ = t.bas + var _ : () = t.bas(0) } func existentialClassP(p: ClassP) { - var bas = p.bas // expected-error{{partial application of protocol method is not allowed}} - var basFull : () = p.bas(0) + var _ = p.bas // expected-error{{partial application of protocol method is not allowed}} + var _ : () = p.bas(0) } // @@ -173,8 +173,8 @@ class InstanceOrClassMethod { func testPreferClassMethodToCurriedInstanceMethod(obj: InstanceOrClassMethod) { let result = InstanceOrClassMethod.method(obj) - let resultChecked: Bool = result // no-warning - let curried: () -> Bool = InstanceOrClassMethod.method(obj) + let _: Bool = result // no-warning + let _: () -> Bool = InstanceOrClassMethod.method(obj) } protocol Numeric { diff --git a/test/Constraints/nested_generics.swift b/test/Constraints/nested_generics.swift index 9983bfe764abe..1775f4b6c50d4 100644 --- a/test/Constraints/nested_generics.swift +++ b/test/Constraints/nested_generics.swift @@ -32,7 +32,7 @@ struct AnyStream { typealias Element = (Int, S.Element) mutating func next() -> Element? { - var result = (index, elements.next()) + let result = (index, elements.next()) if result.1 == nil { return .None } ++index return (result.0, result.1!) diff --git a/test/Constraints/optional.swift b/test/Constraints/optional.swift index ef53452f32205..06c138b003d15 100644 --- a/test/Constraints/optional.swift +++ b/test/Constraints/optional.swift @@ -35,7 +35,7 @@ func test1(a: A) { extension Optional { func bind(f: T -> U?) -> U? { switch self { - case .Some(var x): + case .Some(let x): return f(x) case .None: return .None @@ -76,7 +76,7 @@ func test7(x : A) { } func test8(x : AnyObject?) { - let y : A = x as! A + let _ : A = x as! A } @@ -85,10 +85,10 @@ func test9_helper(x: T) -> Int { } func test9_helper(x: T?) -> Double { } func test9(i: Int, io: Int?) { - var result = test9_helper(i) - var i2: Int = result - var result2 = test9_helper(io) - let d: Double = result2 + let result = test9_helper(i) + var _: Int = result + let result2 = test9_helper(io) + let _: Double = result2 } protocol P { } @@ -100,10 +100,10 @@ extension Int : P { } func test10(i: Int, io: Int?) { let result = test10_helper(i) - var i2: Int = result + var _: Int = result let result2 = test10_helper(io) - var d: Double = result2 + var _: Double = result2 } var z: Int? = nil diff --git a/test/Constraints/subscript.swift b/test/Constraints/subscript.swift index 5778963ea452d..3bd6813c5047f 100644 --- a/test/Constraints/subscript.swift +++ b/test/Constraints/subscript.swift @@ -2,7 +2,7 @@ // Simple subscript of arrays: func simpleSubscript(array: [Float], x: Int) -> Float { - var f = array[x] + var _ = array[x] return array[x] } diff --git a/test/Constraints/tuple.swift b/test/Constraints/tuple.swift index 114b0c2adcd5b..84bc12b1e4094 100644 --- a/test/Constraints/tuple.swift +++ b/test/Constraints/tuple.swift @@ -74,7 +74,7 @@ extension Int : PosixErrorReturn { func posixCantFail> (f:(A) -> T)(args:A) -> T { - var result = f(args) + let result = f(args) assert(result != T.errorReturnValue()) return result } @@ -93,4 +93,7 @@ class C { func testLValue(var c: C) { c.f(c) + + let x = c + c = x } diff --git a/test/Constraints/unchecked_optional.swift b/test/Constraints/unchecked_optional.swift index 094a9b14b9563..317ebd4cbed5e 100644 --- a/test/Constraints/unchecked_optional.swift +++ b/test/Constraints/unchecked_optional.swift @@ -35,8 +35,9 @@ struct B { } func test2(var b : B!) { - var x = b.x + let x = b.x b.x = x + b = nil } struct Subscriptable { @@ -57,11 +58,11 @@ func test4(f: (Int -> Float)!) -> Float { } func test5(value : Int!) { - let value2 : Int? = value + let _ : Int? = value } func test6(value : Int!) { - let value2 : Int? = value + let _ : Int? = value } class Test9a {} @@ -69,9 +70,9 @@ class Test9b : Test9a {} func test9_produceUnchecked() -> Test9b! { return Test9b() } func test9_consume(foo : Test9b) {} func test9() -> Test9a { - var foo = test9_produceUnchecked() + let foo = test9_produceUnchecked() test9_consume(foo) - var bar : Test9a = foo + let _ : Test9a = foo return foo } @@ -85,4 +86,5 @@ func test11_helper(t: T) { } func test11(i: Int!, var j: Int!) { test11_helper(i) test11_helper(j) + j = nil } diff --git a/test/DebugInfo/archetypes2.swift b/test/DebugInfo/archetypes2.swift index 27de9dca321e3..ccaabab8ca090 100644 --- a/test/DebugInfo/archetypes2.swift +++ b/test/DebugInfo/archetypes2.swift @@ -7,7 +7,7 @@ class C { // CHECK-DAG: ![[B:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq_FC11archetypes21C3foo // CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", {{.*}}line: [[@LINE+2]],{{.*}}type: ![[A]] // CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "y", {{.*}}line: [[@LINE+1]],{{.*}}type: ![[B]] - func foo (var x : A, var y : B) { + func foo ( x : A, y : B) { markUsed("hello world") } } diff --git a/test/DebugInfo/generic_args.swift b/test/DebugInfo/generic_args.swift index 509c3255583bf..af5e5674d0bb9 100644 --- a/test/DebugInfo/generic_args.swift +++ b/test/DebugInfo/generic_args.swift @@ -20,7 +20,7 @@ class AnotherClass : AProtocol { // CHECK-DAG: ![[T]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq_F12generic_args9aFunction{{.*}} // CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "y", arg: 2,{{.*}} type: ![[Q:.*]]) // CHECK-DAG: ![[Q]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq0_F12generic_args9aFunction{{.*}} -func aFunction(var x: T, var _ y: Q, _ z: String) { +func aFunction(x: T, _ y: Q, _ z: String) { markUsed("I am in \(z): \(x.f()) \(y.f())") } @@ -31,6 +31,8 @@ struct Wrapper { init(from : Wrapper) { // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "Wrapper",{{.*}} identifier: "_TtGV12generic_args7WrapperQq_FS0_cu__Rq_S_9AProtocolqd__S1__FMGS0_q__FT4fromGS0_qd____GS0_q___") var wrapped = from + wrapped = from + _ = wrapped } func passthrough(t: T) -> T { @@ -38,6 +40,7 @@ struct Wrapper { var local = t // The type of local should have the context Wrapper. // CHECK-DAG: ![[LOCAL_T]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq_V12generic_args7Wrapper" + local = t return local } } diff --git a/test/Generics/algorithms.swift b/test/Generics/algorithms.swift index be2cb662ec0bd..a1d3a0da8f583 100644 --- a/test/Generics/algorithms.swift +++ b/test/Generics/algorithms.swift @@ -15,7 +15,7 @@ protocol Comparable: Eq { func find (range : R, value : R.Element) -> R { var result = range - var z = GeneratorSequence(range) +// var z = GeneratorSequence(range) for x in GeneratorSequence(range) { if x == value { break @@ -98,7 +98,7 @@ func mismatch var prev1 = range1, prev2 = range2 while true { - var e1 = range1.next(), e2 = range2.next() + let e1 = range1.next(), e2 = range2.next() if (e1 == nil) || (e2 == nil) || !predicate(e1!, e2!) { break } prev1.next() @@ -166,7 +166,7 @@ func lowerBound (inputrange : R, value : R.Element) -> R { var range = inputrange while range.size() > 1 { - var mid = range.size() / 2 + let mid = range.size() / 2 if range.getNth(mid) < value { range = range[mid + 1.. (inputrange : R, value : R.Element) -> R { var range = inputrange while range.size() > 1 { - var mid = range.size() / 2 + let mid = range.size() / 2 if value < range.getNth(mid) { range = range[0.. { mutating func replace(a: C) { for i in a.startIndex..(t: T) { - var c: C = t.getAssoc() + let _: C = t.getAssoc() t.getAssoc().f() } diff --git a/test/Generics/constrained_optional_params.swift b/test/Generics/constrained_optional_params.swift index 806fcdecf5b80..5ee65440c4df5 100644 --- a/test/Generics/constrained_optional_params.swift +++ b/test/Generics/constrained_optional_params.swift @@ -4,6 +4,6 @@ protocol P { func method() -> Int } func address_only_bind(x: T?) -> Int { - var y = x!.method() + let y = x!.method() return y } diff --git a/test/Generics/deduction.swift b/test/Generics/deduction.swift index 5a7be2b33b509..d1a32c0c75821 100644 --- a/test/Generics/deduction.swift +++ b/test/Generics/deduction.swift @@ -45,7 +45,7 @@ func useTwoIdentical(xi: Int, yi: Float) { func mySwap(inout x: T, inout _ y: T) { - var tmp = x + let tmp = x x = y y = tmp } @@ -182,6 +182,7 @@ func testStatic(sf: StaticFuncs, sfi: StaticFuncsGeneric) { // x = sfi.chameleon() // typealias SFI = StaticFuncsGeneric // x = SFI.chameleon() + _ = x } //===----------------------------------------------------------------------===// diff --git a/test/Generics/function_decls.swift b/test/Generics/function_decls.swift index a6245e35c7f47..7d088614f4922 100644 --- a/test/Generics/function_decls.swift +++ b/test/Generics/function_decls.swift @@ -14,8 +14,8 @@ func f4(x: T, y: T) { } func f5(x: T, y: U) { struct Local { // expected-error {{type 'Local' nested in generic function 'f5' is not allowed}} func f() { - var t : T = 17 // expected-error{{'Int' is not convertible to 'T'}} - var u : U = 17 // okay: refers to 'U' declared within the local class + var _ : T = 17 // expected-error{{'Int' is not convertible to 'T'}} + var _ : U = 17 // okay: refers to 'U' declared within the local class } typealias U = Int } diff --git a/test/Generics/function_defs.swift b/test/Generics/function_defs.swift index 0d081dbb0c388..cbe637a3cbdda 100644 --- a/test/Generics/function_defs.swift +++ b/test/Generics/function_defs.swift @@ -47,11 +47,13 @@ protocol OtherEqualComparable { func otherExistential(t1: T) { var otherEqComp : OtherEqualComparable = t1 // expected-error{{type 'T' does not conform to protocol 'OtherEqualComparable'}} expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} otherEqComp = t1 // expected-error{{cannot assign a value of type 'T' to a value of type 'OtherEqualComparable'}} - + _ = otherEqComp + var otherEqComp2 : OtherEqualComparable // expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} otherEqComp2 = t1 // expected-error{{cannot assign a value of type 'T' to a value of type 'OtherEqualComparable'}} + _ = otherEqComp2 - var everyEq : protocol = t1 // expected-error{{type 'T' does not conform to protocol 'OtherEqualComparable'}} expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} expected-error{{protocol 'EqualComparable' can only be used as a generic constraint}} + var _ : protocol = t1 // expected-error{{type 'T' does not conform to protocol 'OtherEqualComparable'}} expected-error{{protocol 'OtherEqualComparable' can only be used as a generic constraint}} expected-error{{protocol 'EqualComparable' can only be used as a generic constraint}} } protocol Runcible { @@ -186,7 +188,7 @@ func testOrdered(x: T, y: Int) { func conformanceViaRequires(t1: T, t2: T) -> Bool { - var b1 = t1.isEqual(t2) + let b1 = t1.isEqual(t2) if b1 || t1.isLess(t2) { return true; } @@ -204,7 +206,7 @@ protocol AcceptsAnElement { func impliedSameType(t: T) { t.accept(t.generate()) - var e = t.generate(), e2 = t.generate() + let e = t.generate(), e2 = t.generate() if e.isEqual(e2) || e.isLess(e2) { return } @@ -243,7 +245,7 @@ func recursiveSameType (t: T, u: U) { t.get().accept(t.get().generate()) - var e = t.get().generate(), e2 = t.get().generate() + let e = t.get().generate(), e2 = t.get().generate() if e.isEqual(e2) || e.isLess(e2) { return } diff --git a/test/Generics/generic_types.swift b/test/Generics/generic_types.swift index 1393e510d16fe..eba8555a795e9 100644 --- a/test/Generics/generic_types.swift +++ b/test/Generics/generic_types.swift @@ -70,8 +70,8 @@ func getFirst(var r: R) -> R.Element { return r.next()! } -func testGetFirst(var ir: Range) { - var i : Int = getFirst(ir.generate()) +func testGetFirst(ir: Range) { + var _ : Int = getFirst(ir.generate()) } struct XT { @@ -272,11 +272,11 @@ var xarray : XArray = [1, 2, 3] // Type parameters can be referenced only via unqualified name lookup struct XParam { func foo(x: T) { - var y : T = x + var _ : T = x } static func bar(x: T) { - var y : T = x + var _ : T = x } } diff --git a/test/Generics/inheritance.swift b/test/Generics/inheritance.swift index 7dd7b44064a26..f5764af3f635d 100644 --- a/test/Generics/inheritance.swift +++ b/test/Generics/inheritance.swift @@ -54,8 +54,8 @@ class Y : X<[T]> { } func testGenericInherit() { - var yi : Y - var ia : [Int] = yi.f() + let yi : Y + var _ : [Int] = yi.f() } diff --git a/test/Generics/same_type_constraints.swift b/test/Generics/same_type_constraints.swift index cac9044f82252..91e0ef89b6fb0 100644 --- a/test/Generics/same_type_constraints.swift +++ b/test/Generics/same_type_constraints.swift @@ -175,7 +175,7 @@ struct SpecificAnimal : Animal { typealias EdibleFood=F let _eat:(f:F)->() - init(var _ selfie:A) { + init(_ selfie:A) { _eat = { selfie.eat($0) } } func eat(f:F) { diff --git a/test/Generics/slice_test.swift b/test/Generics/slice_test.swift index 865dd289476c8..82a8062a4f8fb 100644 --- a/test/Generics/slice_test.swift +++ b/test/Generics/slice_test.swift @@ -20,8 +20,8 @@ infix operator != { func testslice(s: Array) { for i in 0.. UnsafeMutablePointer @@ -40,9 +40,9 @@ class Vector { func push_back(elem: T) { if length == capacity { - var newcapacity = capacity * 2 + 2 - var size = Int(Builtin.sizeof(T.self)) - var newbase = UnsafeMutablePointer(c_malloc(newcapacity * size)) + let newcapacity = capacity * 2 + 2 + let size = Int(Builtin.sizeof(T.self)) + let newbase = UnsafeMutablePointer(c_malloc(newcapacity * size)) for i in 0..(inout array: [T]) { for i in 0.. { func f() -> GS { - var gs = GS() + let gs = GS() return gs } struct Nested { // expected-error{{nested in generic type}} func ff() -> GS { - var gs = GS() + let gs = GS() return gs } } struct NestedGeneric { // expected-note{{generic type 'NestedGeneric' declared here}} // expected-error{{generic type 'NestedGeneric' nested in type}} func fff() -> (GS, NestedGeneric) { - var gs = GS() - var ns = NestedGeneric() + let gs = GS() + let ns = NestedGeneric() return (gs, ns) } } @@ -62,12 +62,12 @@ struct GS { extension GS { func g() -> GS { - var gs = GS() + let gs = GS() return gs } func h() { - var gs : GS = GS() // expected-error{{'GS' is not convertible to 'GS'}} + var _ : GS = GS() // expected-error{{'GS' is not convertible to 'GS'}} } } @@ -75,14 +75,14 @@ class GC { init() {} func f() -> GC { - var gc = GC() + let gc = GC() return gc } } extension GC { func g() -> GC { - var gc = GC() + let gc = GC() return gc } } diff --git a/test/IDE/complete_from_clang_framework_typechecker.swift b/test/IDE/complete_from_clang_framework_typechecker.swift index a6b8b57695d29..67fb0a177e791 100644 --- a/test/IDE/complete_from_clang_framework_typechecker.swift +++ b/test/IDE/complete_from_clang_framework_typechecker.swift @@ -6,12 +6,12 @@ import Foo // Don't import 'FooHelper'. func test1() { - let a = Foo.FooEnum1X - let b = Foo.FooSubEnum1X + let _ = Foo.FooEnum1X + let _ = Foo.FooSubEnum1X // Even though 'FooHelper' is a separate module, because 'Foo' re-exports it, // we allow qualifying members of 'FooHelper' with 'Foo'. // If this changes, code completion needs to change. - let c = Foo.FooHelperSubEnum1X + let _ = Foo.FooHelperSubEnum1X } diff --git a/test/IDE/print_ast_tc_decls.swift b/test/IDE/print_ast_tc_decls.swift index eced94ca1152b..5a4521effd52a 100644 --- a/test/IDE/print_ast_tc_decls.swift +++ b/test/IDE/print_ast_tc_decls.swift @@ -121,7 +121,7 @@ struct d0100_FooStruct { func instanceFunc2(a: Int, inout b: Double) {} // PASS_COMMON-NEXT: {{^}} func instanceFunc2(a: Int, inout b: Double){{$}} - func instanceFunc3(var a: Int, let b: Double) {} + func instanceFunc3(var a: Int, let b: Double) { a = 1} // PASS_COMMON-NEXT: {{^}} func instanceFunc3(a: Int, b: Double){{$}} func instanceFuncWithDefaultArg1(a: Int = 0) {} diff --git a/test/IDE/print_types.swift b/test/IDE/print_types.swift index f95317cd499ac..bfdfbf05aa22c 100644 --- a/test/IDE/print_types.swift +++ b/test/IDE/print_types.swift @@ -17,42 +17,52 @@ func testVariableTypes(param: Int, inout param2: Double) { // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''a1''' Swift.Int{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + a1 = 17; _ = a1 + var a2 : Int = 42 // CHECK: VarDecl '''a2''' Int{{$}} // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''a2''' Swift.Int{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + a2 = 17; _ = a2 var a3 = Int16(42) // CHECK: VarDecl '''a3''' Int16{{$}} // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''a3''' Swift.Int16{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + a3 = 17; _ = a3 + var a4 = Int32(42) // CHECK: VarDecl '''a4''' Int32{{$}} // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''a4''' Swift.Int32{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + a4 = 17; _ = a4 var a5 : Int64 = 42 // CHECK: VarDecl '''a5''' Int64{{$}} // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''a5''' Swift.Int64{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + a5 = 17; _ = a5 var typealias1 : MyInt = 42 // CHECK: VarDecl '''typealias1''' MyInt{{$}} // CHECK: IntegerLiteralExpr:[[@LINE-2]] '''42''' Int2048{{$}} // FULL: VarDecl '''typealias1''' swift_ide_test.MyInt{{$}} // FULL: IntegerLiteralExpr:[[@LINE-4]] '''42''' Builtin.Int2048{{$}} + _ = typealias1 ; typealias1 = 1 var optional1 = Optional.None // CHECK: VarDecl '''optional1''' Optional{{$}} // FULL: VarDecl '''optional1''' Swift.Optional{{$}} + _ = optional1 ; optional1 = nil var optional2 = Optional<[Int]>.None + _ = optional2 ; optional2 = nil // CHECK: VarDecl '''optional2''' Optional<[Int]>{{$}} // FULL: VarDecl '''optional2''' Swift.Optional<[Swift.Int]>{{$}} } @@ -104,14 +114,17 @@ func testInGenericFunc1> (A, b: B, c: C) -> (){{$}} var a1 = a + _ = a1; a1 = a // CHECK: VarDecl '''a1''' A{{$}} // FULL: VarDecl '''a1''' A{{$}} var b1 = b + _ = b1; b1 = b // CHECK: VarDecl '''b1''' B{{$}} // FULL: VarDecl '''b1''' B{{$}} var gs1 = GenericStruct() + _ = gs1; gs1 = GenericStruct() // CHECK: VarDecl '''gs1''' GenericStruct{{$}} // CHECK: CallExpr:[[@LINE-2]] '''GenericStruct()''' GenericStruct{{$}} // CHECK: ConstructorRefCallExpr:[[@LINE-3]] '''GenericStruct''' () -> GenericStruct diff --git a/test/IDE/print_usrs.swift b/test/IDE/print_usrs.swift index b3a4e6a63ef5d..42c1c323a91ea 100644 --- a/test/IDE/print_usrs.swift +++ b/test/IDE/print_usrs.swift @@ -176,5 +176,7 @@ func importedMacros() { let m2 = MACRO_FROM_IMPL // CHECK: [[@LINE+1]]:12 c:@macro@USES_MACRO_FROM_OTHER_MODULE_1{{$}} let m3 = USES_MACRO_FROM_OTHER_MODULE_1 + + _ = m1; _ = m2; _ = m3 } diff --git a/test/SILPasses/capture_promotion.swift b/test/SILPasses/capture_promotion.swift index 4a95937f2fa7d..ce3d891e5705b 100644 --- a/test/SILPasses/capture_promotion.swift +++ b/test/SILPasses/capture_promotion.swift @@ -16,9 +16,9 @@ struct Baz { // CHECK: sil hidden @_TF17capture_promotion22test_capture_promotionFT_FT_Si func test_capture_promotion() -> () -> Int { - var x : Int = 1 - var y : Foo = Foo() - var z : Baz = Baz() + var x : Int = 1; x = 1 + var y : Foo = Foo(); y = Foo() + var z : Baz = Baz(); z = Baz() // CHECK-NOT: alloc_box diff --git a/test/SILPasses/diagnostic_constant_propagation.swift b/test/SILPasses/diagnostic_constant_propagation.swift index 60762f3b78cd0..10517bd4126d3 100644 --- a/test/SILPasses/diagnostic_constant_propagation.swift +++ b/test/SILPasses/diagnostic_constant_propagation.swift @@ -7,30 +7,30 @@ // These are tests for diagnostics produced by constant propagation pass. func testArithmeticOverflow() { - var xu8 : UInt8 = 250 - var yu8 : UInt8 = 250 - var zu8 = xu8 + yu8 // expected-error {{arithmetic operation '250 + 250' (on type 'UInt8') results in an overflow}} - var xpyu8 : UInt8 = 250 + 250 // expected-error {{arithmetic operation '250 + 250' (on type 'UInt8') results in an overflow}} - var xpyi8 : Int8 = 126 + 126 // expected-error {{arithmetic operation '126 + 126' (on type 'Int8') results in an overflow}} - var xmyu16 : UInt16 = 65000 * 2 // expected-error {{arithmetic operation '65000 * 2' (on type 'UInt16') results in an overflow}} - var xmyi16 : Int16 = 32000 * 2 // expected-error {{arithmetic operation '32000 * 2' (on type 'Int16') results in an overflow}} - var xmyu32 : UInt32 = 4294967295 * 30 // expected-error {{arithmetic operation '4294967295 * 30' (on type 'UInt32') results in an overflow}} - var xpyi32 : Int32 = 2147483647 + 30 // expected-error {{arithmetic operation '2147483647 + 30' (on type 'Int32') results in an overflow}} - var xpyu64 : UInt64 = 9223372036854775807 * 30 // expected-error {{results in an overflow}} - var xpyi64 : Int64 = 9223372036854775807 + 1 // expected-error {{results in an overflow}} + let xu8 : UInt8 = 250 + let yu8 : UInt8 = 250 + var _ /*zu8*/ = xu8 + yu8 // expected-error {{arithmetic operation '250 + 250' (on type 'UInt8') results in an overflow}} + var _ /*xpyu8*/ : UInt8 = 250 + 250 // expected-error {{arithmetic operation '250 + 250' (on type 'UInt8') results in an overflow}} + var _ /*xpyi8*/ : Int8 = 126 + 126 // expected-error {{arithmetic operation '126 + 126' (on type 'Int8') results in an overflow}} + var _ /*xmyu16*/ : UInt16 = 65000 * 2 // expected-error {{arithmetic operation '65000 * 2' (on type 'UInt16') results in an overflow}} + var _ /*xmyi16*/ : Int16 = 32000 * 2 // expected-error {{arithmetic operation '32000 * 2' (on type 'Int16') results in an overflow}} + var _ /*xmyu32*/ : UInt32 = 4294967295 * 30 // expected-error {{arithmetic operation '4294967295 * 30' (on type 'UInt32') results in an overflow}} + var _ /*xpyi32*/ : Int32 = 2147483647 + 30 // expected-error {{arithmetic operation '2147483647 + 30' (on type 'Int32') results in an overflow}} + var _ /*xpyu64*/ : UInt64 = 9223372036854775807 * 30 // expected-error {{results in an overflow}} + var _ /*xpyi64*/ : Int64 = 9223372036854775807 + 1 // expected-error {{results in an overflow}} var xu8_2 : UInt8 = 240 xu8_2 += 40 // expected-error {{arithmetic operation '240 + 40' (on type 'UInt8') results in an overflow}} - var x : UInt8 = 230 - 240 // expected-error {{arithmetic operation '230 - 240' (on type 'UInt8') results in an overflow}} + var _ : UInt8 = 230 - 240 // expected-error {{arithmetic operation '230 - 240' (on type 'UInt8') results in an overflow}} var xu8_3 : UInt8 = 240 // Global (cross block) analysis. - for i in 0..<10 {} + for _ in 0..<10 {} xu8_3 += 40 // expected-error {{arithmetic operation '240 + 40' (on type 'UInt8') results in an overflow}} - var cadd : UInt8 = 240 + 5 + 15 // expected-error {{arithmetic operation '245 + 15' (on type 'UInt8') results in an overflow}} + var _ : UInt8 = 240 + 5 + 15 // expected-error {{arithmetic operation '245 + 15' (on type 'UInt8') results in an overflow}} // TODO: We should remove the second init for Int8 - see rdar://problem/19224768 - let ranges = Int8(126) + Int8(1+1) // expected-error {{arithmetic operation '126 + 2' (on type 'Int8') results in an overflow}} + let _ = Int8(126) + Int8(1+1) // expected-error {{arithmetic operation '126 + 2' (on type 'Int8') results in an overflow}} // DISABLED FOR NOW // asserts in the shift operators confuse constant propagation // var csh1: Int8 = (1 << 7) - 1 // expected - error {{arithmetic operation '-128 - 1' (on type 'Int8') results in an overflow}} @@ -54,99 +54,99 @@ func testGenericArithmeticOverflowMessage() { typealias MyInt = UInt8; func testConvertOverflow() { - var int8_minus_two : Int8 = (-2) - var int8_plus_two : Int8 = (2) - var int16_minus_two : Int16 = (-2) - var int16_plus_two : Int16 = (2) - var int32_minus_two : Int32 = (-2) - var int32_plus_two : Int32 = (2) - var int64_minus_two : Int64 = (-2) - var int64_plus_two : Int64 = (2) - var int_minus_two : Int = (-2) - var int_plus_two : Int = (2) - var convert_minus_two = Int8(int_minus_two) - var convert_plus_two = Int8(int_plus_two) - - var uint8_minus_two : UInt8 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt8'}} - var uint8_plus_two : UInt8 = (2) - var uint16_minus_two : UInt16 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt16'}} - var uint16_plus_two : UInt16 = (2) - var uint32_minus_two : UInt32 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt32'}} - var uint32_plus_two : UInt32 = (2) - var uint64_minus_two : UInt64 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt64'}} - var uint64_plus_two : UInt64 = (2) - var convert_s_to_u_minus_two = UInt8(int_minus_two) // expected-error {{integer overflows when converted from 'Int' to 'UInt8'}} - var convert_s_to_u_plus_two = UInt8(int_plus_two) - var convert_u_to_s_plus_two = Int8(uint32_plus_two) - - var int8_min : Int8 = (-128) - var int8_min_m1 : Int8 = (-129) // expected-error {{integer literal '-129' overflows when stored into 'Int8'}} - var int16_min : Int16 = (-32768) - var int16_min_m1 : Int16 = (-32769) // expected-error {{integer literal '-32769' overflows when stored into 'Int16'}} - var int32_min : Int32 = (-2147483648) - var int32_min_m1 : Int32 = (-2147483649) // expected-error {{integer literal '-2147483649' overflows when stored into 'Int32'}} - var int64_min : Int64 = (-9223372036854775808) - var int64_min_m1 : Int64 = (-9223372036854775809) // expected-error {{integer literal '-9223372036854775809' overflows when stored into 'Int64'}} - var int_minus_128 = -128 - var int8_min_conv = Int8(int_minus_128) - var int_minus_129 = -129 - var int8_min_m1_conv = Int8(int_minus_129) // expected-error {{integer overflows when converted from 'Int' to 'Int8'}} - - var int8_max : Int8 = (127) - var int8_max_p1 : Int8 = (128) // expected-error {{integer literal '128' overflows when stored into 'Int8'}} - var int16_max : Int16 = (32767) - var int16_max_p1 : Int16 = (32768) // expected-error {{integer literal '32768' overflows when stored into 'Int16'}} - var int32_max : Int32 = (2147483647) - var int32_max_p1 : Int32 = (2147483648) // expected-error {{integer literal '2147483648' overflows when stored into 'Int32'}} - var int64_max : Int64 = (9223372036854775807) - var int64_max_p1 : Int64 = (9223372036854775808) // expected-error {{integer literal '9223372036854775808' overflows when stored into 'Int64'}} - var int16_max_conv = Int16(UInt64(int16_max)) - var uint64_plus_32768 : UInt64 = 32768 - var int16_max_p1_conv = Int16(uint64_plus_32768) // expected-error {{integer overflows when converted from 'UInt64' to 'Int16'}} + var _ /*int8_minus_two*/ : Int8 = (-2) + var _ /*int8_plus_two*/ : Int8 = (2) + var _ /*int16_minus_two*/ : Int16 = (-2) + var _ /*int16_plus_two*/ : Int16 = (2) + var _ /*int32_minus_two*/ : Int32 = (-2) + var _ /*int32_plus_two*/ : Int32 = (2) + var _ /*int64_minus_two*/ : Int64 = (-2) + var _ /*int64_plus_two*/ : Int64 = (2) + let int_minus_two : Int = (-2) + let int_plus_two : Int = (2) + var _ /*convert_minus_two*/ = Int8(int_minus_two) + var _ /*convert_plus_two*/ = Int8(int_plus_two) + + var _ /*uint8_minus_two*/ : UInt8 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt8'}} + var _ /*uint8_plus_two*/ : UInt8 = (2) + var _ /*uint16_minus_two*/ : UInt16 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt16'}} + var _ /*uint16_plus_two*/ : UInt16 = (2) + var _ /*uint32_minus_two*/ : UInt32 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt32'}} + let uint32_plus_two : UInt32 = (2) + var _ /*uint64_minus_two*/ : UInt64 = (-2) // expected-error {{negative integer '-2' overflows when stored into unsigned type 'UInt64'}} + var _ /*uint64_plus_two*/ : UInt64 = (2) + var _ /*convert_s_to_u_minus_two*/ = UInt8(int_minus_two) // expected-error {{integer overflows when converted from 'Int' to 'UInt8'}} + var _ /*convert_s_to_u_plus_two*/ = UInt8(int_plus_two) + var _ /*convert_u_to_s_plus_two*/ = Int8(uint32_plus_two) + + var _ /*int8_min*/ : Int8 = (-128) + var _ /*int8_min_m1*/ : Int8 = (-129) // expected-error {{integer literal '-129' overflows when stored into 'Int8'}} + var _ /*int16_min*/ : Int16 = (-32768) + var _ /*int16_min_m1*/ : Int16 = (-32769) // expected-error {{integer literal '-32769' overflows when stored into 'Int16'}} + var _ /*int32_min*/ : Int32 = (-2147483648) + var _ /*int32_min_m1*/ : Int32 = (-2147483649) // expected-error {{integer literal '-2147483649' overflows when stored into 'Int32'}} + var _ /*int64_min*/ : Int64 = (-9223372036854775808) + var _ /*int64_min_m1*/ : Int64 = (-9223372036854775809) // expected-error {{integer literal '-9223372036854775809' overflows when stored into 'Int64'}} + let int_minus_128 = -128 + var _ /*int8_min_conv*/ = Int8(int_minus_128) + let int_minus_129 = -129 + var _ /*int8_min_m1_conv*/ = Int8(int_minus_129) // expected-error {{integer overflows when converted from 'Int' to 'Int8'}} + + var _ /*int8_max*/ : Int8 = (127) + var _ /*int8_max_p1*/ : Int8 = (128) // expected-error {{integer literal '128' overflows when stored into 'Int8'}} + let int16_max : Int16 = (32767) + var _ /*int16_max_p1*/ : Int16 = (32768) // expected-error {{integer literal '32768' overflows when stored into 'Int16'}} + var _ /*int32_max*/ : Int32 = (2147483647) + var _ /*int32_max_p1*/ : Int32 = (2147483648) // expected-error {{integer literal '2147483648' overflows when stored into 'Int32'}} + var _ /*int64_max*/ : Int64 = (9223372036854775807) + var _ /*int64_max_p1*/ : Int64 = (9223372036854775808) // expected-error {{integer literal '9223372036854775808' overflows when stored into 'Int64'}} + var _ /*int16_max_conv*/ = Int16(UInt64(int16_max)) + let uint64_plus_32768 : UInt64 = 32768 + var _ /*int16_max_p1_conv*/ = Int16(uint64_plus_32768) // expected-error {{integer overflows when converted from 'UInt64' to 'Int16'}} - var int8_max_pa : Int8 = -13333; //expected-error{{integer literal '-13333' overflows when stored into 'Int8}} - var int32_max_p_hex : Int32 = 0xFFFF_FFFF; //expected-error{{integer literal '4294967295' overflows when stored into 'Int32'}} - var uint32_max_hex : UInt32 = 0xFFFF_FFFF; - var uint32_max_p_hex : UInt32 = 0xFFFF_FFFF_F; //expected-error{{integer literal '68719476735' overflows when stored into 'UInt32'}} - var uint0_typealias : MyInt = 256; //expected-error{{integer literal '256' overflows when stored into 'MyInt'}} - - var uint8_min : UInt8 = (0) - var uint16_min : UInt16 = (0) - var uint32_min : UInt32 = (0) - var uint64_min : UInt64 = (0) - var uint8_min_conv_to_u = UInt8(uint64_min) - - var int8_zero : Int8 = (0) - var int16_zero : Int16 = (0) - var int32_zero : Int32 = (0) - var int64_zero : Int64 = (0) - var int8_min_conv_to_s = Int8(uint16_min) - - var uint8_max : UInt8 = (255) - var uint8_max_p1 : UInt8 = (256) // expected-error {{integer literal '256' overflows when stored into 'UInt8'}} - var uint16_max : UInt16 = (65535) - var uint16_max_p1 : UInt16 = (65536) // expected-error {{integer literal '65536' overflows when stored into 'UInt16'}} - var uint32_max : UInt32 = (4294967295) - var uint32_max_p1 : UInt32 = (4294967296) // expected-error {{integer literal '4294967296' overflows when stored into 'UInt32'}} - var uint64_max : UInt64 = (18446744073709551615) - var uint64_max_p1 : UInt64 = (18446744073709551616) // expected-error {{integer literal '18446744073709551616' overflows when stored into 'UInt64'}} - var uint16_255 : UInt16 = 255 - var uint8_max_conv = UInt8(uint16_255) - var uint16_256 : UInt16 = 256 - var uint8_max_p1_conv = UInt8(uint16_256) // expected-error {{integer overflows when converted from 'UInt16' to 'UInt8'}} + var _ /*int8_max_pa*/ : Int8 = -13333; //expected-error{{integer literal '-13333' overflows when stored into 'Int8}} + var _ /*int32_max_p_hex*/ : Int32 = 0xFFFF_FFFF; //expected-error{{integer literal '4294967295' overflows when stored into 'Int32'}} + var _ /*uint32_max_hex*/ : UInt32 = 0xFFFF_FFFF; + var _ /*uint32_max_p_hex*/ : UInt32 = 0xFFFF_FFFF_F; //expected-error{{integer literal '68719476735' overflows when stored into 'UInt32'}} + var _ /*uint0_typealias*/ : MyInt = 256; //expected-error{{integer literal '256' overflows when stored into 'MyInt'}} + + var _ /*uint8_min*/ : UInt8 = (0) + let uint16_min : UInt16 = (0) + var _ /*uint32_min*/ : UInt32 = (0) + let uint64_min : UInt64 = (0) + var _ /*uint8_min_conv_to_u*/ = UInt8(uint64_min) + + let int8_zero : Int8 = (0) + var _ /*int16_zero*/ : Int16 = (0) + var _ /*int32_zero*/ : Int32 = (0) + var _ /*int64_zero*/ : Int64 = (0) + var _ /*int8_min_conv_to_s*/ = Int8(uint16_min) + + var _ /*uint8_max*/ : UInt8 = (255) + var _ /*uint8_max_p1*/ : UInt8 = (256) // expected-error {{integer literal '256' overflows when stored into 'UInt8'}} + var _ /*uint16_max*/ : UInt16 = (65535) + var _ /*uint16_max_p1*/ : UInt16 = (65536) // expected-error {{integer literal '65536' overflows when stored into 'UInt16'}} + var _ /*uint32_max*/ : UInt32 = (4294967295) + var _ /*uint32_max_p1*/ : UInt32 = (4294967296) // expected-error {{integer literal '4294967296' overflows when stored into 'UInt32'}} + var _ /*uint64_max*/ : UInt64 = (18446744073709551615) + var _ /*uint64_max_p1*/ : UInt64 = (18446744073709551616) // expected-error {{integer literal '18446744073709551616' overflows when stored into 'UInt64'}} + let uint16_255 : UInt16 = 255 + var _ /*uint8_max_conv*/ = UInt8(uint16_255) + let uint16_256 : UInt16 = 256 + var _ /*uint8_max_p1_conv*/ = UInt8(uint16_256) // expected-error {{integer overflows when converted from 'UInt16' to 'UInt8'}} // Check same size int conversions. - var int8_minus_1 : Int8 = -1 - var ssint8_neg = UInt8(int8_minus_1) // expected-error {{negative integer cannot be converted to unsigned type 'UInt8'}} - var uint8_128 : UInt8 = 128 - var ssint8_toobig = Int8(uint8_128) // expected-error {{integer overflows when converted from 'UInt8' to 'Int8'}} - var uint8_127 : UInt8 = 127 - var ssint8_good = Int8(uint8_127) - var int8_127 : Int8 = 127 - var ssint8_good2 = UInt8(int8_127) - var ssint8_zero = UInt8(int8_zero) - var uint8_zero : UInt8 = 0 - var ssint8_zero2 = Int8(uint8_zero) + let int8_minus_1 : Int8 = -1 + let _ /*ssint8_neg*/ = UInt8(int8_minus_1) // expected-error {{negative integer cannot be converted to unsigned type 'UInt8'}} + let uint8_128 : UInt8 = 128 + let _ /*ssint8_toobig*/ = Int8(uint8_128) // expected-error {{integer overflows when converted from 'UInt8' to 'Int8'}} + let uint8_127 : UInt8 = 127 + let _ /*ssint8_good*/ = Int8(uint8_127) + let int8_127 : Int8 = 127 + let _ /*ssint8_good2*/ = UInt8(int8_127) + let _ /*ssint8_zero*/ = UInt8(int8_zero) + let uint8_zero : UInt8 = 0 + let _ /*ssint8_zero2*/ = Int8(uint8_zero) // Check signed to unsigned extending size conversions. UInt16(Int8(-1)) // expected-error{{negative integer cannot be converted to unsigned type 'UInt16'}} @@ -159,52 +159,52 @@ func testConvertOverflow() { UInt64(UInt32(200)) // IEEE binary32 max value = 2^128 * (2^23-1)/2^23 - var float32_max : Float32 = (340282326356119256160033759537265639424) - var float32_max_p1 : Float32 = (340282326356119256160033759537265639425) + var _ /*float32_max*/ : Float32 = (340282326356119256160033759537265639424) + var _ /*float32_max_p1*/ : Float32 = (340282326356119256160033759537265639425) // 2^128 * (2^25-1)/2^25 - 1 - var float32_max_not_yet_overflow : Float32 = (340282356779733661637539395458142568447) + var _ /*float32_max_not_yet_overflow*/ : Float32 = (340282356779733661637539395458142568447) // 2^128 * (2^25-1)/2^25 - var float32_max_first_overflow : Float32 = (340282356779733661637539395458142568448) // expected-error {{integer literal '340282356779733661637539395458142568448' overflows when stored into 'Float32'}} + var _ /*float32_max_first_overflow*/ : Float32 = (340282356779733661637539395458142568448) // expected-error {{integer literal '340282356779733661637539395458142568448' overflows when stored into 'Float32'}} // 2^128 - var float32_max_definitely_overflow : Float32 = (340282366920938463463374607431768211456) // expected-error {{integer literal '340282366920938463463374607431768211456' overflows when stored into 'Float32'}} + var _ /*float32_max_definitely_overflow*/ : Float32 = (340282366920938463463374607431768211456) // expected-error {{integer literal '340282366920938463463374607431768211456' overflows when stored into 'Float32'}} // IEEE binary32 min value = -1 * 2^128 * (2^23-1)/2^23 - var float32_min : Float32 = (-340282326356119256160033759537265639424) - var float32_min_p1 : Float32 = (-340282326356119256160033759537265639425) + var _ /*float32_min*/ : Float32 = (-340282326356119256160033759537265639424) + var _ /*float32_min_p1*/ : Float32 = (-340282326356119256160033759537265639425) // -1 * 2^128 * (2^25-1)/2^25 - 1 - var float32_min_not_yet_overflow : Float32 = (-340282356779733661637539395458142568447) + var _ /*float32_min_not_yet_overflow*/ : Float32 = (-340282356779733661637539395458142568447) // -1 * 2^128 * (2^25-1)/2^25 - var float32_min_first_overflow : Float32 = (-340282356779733661637539395458142568448) // expected-error {{integer literal '-340282356779733661637539395458142568448' overflows when stored into 'Float32'}} + var _ /*float32_min_first_overflow*/ : Float32 = (-340282356779733661637539395458142568448) // expected-error {{integer literal '-340282356779733661637539395458142568448' overflows when stored into 'Float32'}} // -1 * 2^128 - var float32_min_definitely_overflow : Float32 = (-340282366920938463463374607431768211456) // expected-error {{integer literal '-340282366920938463463374607431768211456' overflows when stored into 'Float32'}} + var _ /*float32_min_definitely_overflow*/ : Float32 = (-340282366920938463463374607431768211456) // expected-error {{integer literal '-340282366920938463463374607431768211456' overflows when stored into 'Float32'}} // IEEE binary64 max value = 2^1024 * (2^52-1)/2^52 - var float64_max : Float64 = (179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) - var float64_max_p1 : Float64 = (179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) + var _ /*float64_max*/ : Float64 = (179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) + var _ /*float64_max_p1*/ : Float64 = (179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) // 2^1024 * (2^54-1)/2^54 - 1 - var float64_max_not_yet_overflow : Float64 = (179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791) + var _/*float64_max_not_yet_overflow*/ : Float64 = (179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791) // 2^1024 * (2^54-1)/2^54 - var float64_max_first_overflow : Float64 = (179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792) // expected-error {{integer literal '179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792' overflows when stored into 'Double'}} + var _ /*float64_max_first_overflow*/ : Float64 = (179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792) // expected-error {{integer literal '179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792' overflows when stored into 'Double'}} // 2^1024 - var float64_max_definitely_overflow : Float64 = (179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216) // expected-error {{integer literal '179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216' overflows when stored into 'Double'}} + var _/*float64_max_definitely_overflow*/ : Float64 = (179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216) // expected-error {{integer literal '179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216' overflows when stored into 'Double'}} // IEEE binary64 min value = -1 * 2^1024 * (2^52-1)/2^52 - var float64_min : Float64 = (-179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) - var float64_min_p1 : Float64 = (-179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) + var _/*float64_min*/ : Float64 = (-179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) + var _/*float64_min_p1*/ : Float64 = (-179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520) // -1 * 2^1024 * (2^54-1)/2^54 - 1 - var float64_min_not_yet_overflow : Float64 = (-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791) + var _/*float64_min_not_yet_overflow*/ : Float64 = (-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791) // -1 * 2^1024 * (2^54-1)/2^54 - var float64_min_first_overflow : Float64 = (-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792) // expected-error {{integer literal '-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792' overflows when stored into 'Double'}} + var _/*float64_min_first_overflow*/ : Float64 = (-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792) // expected-error {{integer literal '-179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792' overflows when stored into 'Double'}} // -1 * 2^1024 - var float64_min_definitely_overflow : Float64 = (-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216) // expected-error {{integer literal '-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216' overflows when stored into 'Double'}} + var _/*float64_min_definitely_overflow*/ : Float64 = (-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216) // expected-error {{integer literal '-179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216' overflows when stored into 'Double'}} } @transparent @@ -369,7 +369,7 @@ func testPreDecOverflow() { } func testAssumeNonNegative() { - var input = -3 + let input = -3 _assumeNonNegative(input); // expected-error {{assumed non-negative value '-3' is negative}} } diff --git a/test/Sema/Inputs/enum_raw_multi1.swift b/test/Sema/Inputs/enum_raw_multi1.swift index 89ab326769675..c96f6fdcfd39b 100644 --- a/test/Sema/Inputs/enum_raw_multi1.swift +++ b/test/Sema/Inputs/enum_raw_multi1.swift @@ -1,3 +1,3 @@ func foo() { - let x: GraphicType? = GraphicType(rawValue: 0) + let _: GraphicType? = GraphicType(rawValue: 0) } diff --git a/test/Sema/availability.swift b/test/Sema/availability.swift index a3b470e70d25f..1090a5266b3b7 100644 --- a/test/Sema/availability.swift +++ b/test/Sema/availability.swift @@ -44,7 +44,7 @@ func testInit() { } func testSuvscript(cwu: ClassWithUnavailable) { - let x = cwu[5] // expected-error{{'subscript' is unavailable}} + let _ = cwu[5] // expected-error{{'subscript' is unavailable}} } /* FIXME 'nil == a' fails to type-check with a bogus error message diff --git a/test/Sema/availability_versions.swift b/test/Sema/availability_versions.swift index aa498247c354d..8b72c8f44cc33 100644 --- a/test/Sema/availability_versions.swift +++ b/test/Sema/availability_versions.swift @@ -770,7 +770,7 @@ class ClassWithDeclarationsOfUnavailableClasses { } func methodWithUnavailableLocalDeclaration() { - let o : ClassAvailableOn10_10 = methodWithUnavailableReturnType() // expected-error {{'ClassAvailableOn10_10' is only available on OS X 10.10 or newer}} + let _ : ClassAvailableOn10_10 = methodWithUnavailableReturnType() // expected-error {{'ClassAvailableOn10_10' is only available on OS X 10.10 or newer}} // expected-note@-1 {{add @availability attribute to enclosing class}} // expected-note@-2 {{add @availability attribute to enclosing instance method}} // expected-note@-3 {{guard with version check}} @@ -778,7 +778,7 @@ class ClassWithDeclarationsOfUnavailableClasses { @availability(OSX, introduced=10.10) func unavailableMethodWithUnavailableLocalDeclaration() { - let o : ClassAvailableOn10_10 = methodWithUnavailableReturnType() + let _ : ClassAvailableOn10_10 = methodWithUnavailableReturnType() } } @@ -1073,6 +1073,7 @@ func useGuardAvailable() { if globalFuncAvailableOn10_10() > 0 { guard #available(OSX 10.11, *), let x = injectToOptional(globalFuncAvailableOn10_11()) else { return } + _ = x } let _ = globalFuncAvailableOn10_11() // expected-error {{'globalFuncAvailableOn10_11()' is only available on OS X 10.11 or newer}} @@ -1220,7 +1221,7 @@ class X { } func testForFixitWithNestedMemberRefExpr() { - var x = X() + let x = X() x.y.z = globalFuncAvailableOn10_11() // expected-error@-1 {{'globalFuncAvailableOn10_11()' is only available on OS X 10.11 or newer}} @@ -1228,7 +1229,7 @@ func testForFixitWithNestedMemberRefExpr() { // expected-note@-3 {{add @availability attribute to enclosing global function}} {{1-1=@availability(OSX, introduced=10.11)\n}} // Access via dynamic member reference - var anyX: AnyObject = x + let anyX: AnyObject = x anyX.y?.z = globalFuncAvailableOn10_11() // expected-error@-1 {{'globalFuncAvailableOn10_11()' is only available on OS X 10.11 or newer}} // expected-note@-2 {{guard with version check}} {{3-43=if #available(OSX 10.11, *) {\n anyX.y?.z = globalFuncAvailableOn10_11()\n } else {\n // Fallback on earlier versions\n }}} diff --git a/test/Sema/availability_versions_multi.swift b/test/Sema/availability_versions_multi.swift index f869aa5014d06..30077d50c854f 100644 --- a/test/Sema/availability_versions_multi.swift +++ b/test/Sema/availability_versions_multi.swift @@ -37,7 +37,7 @@ func useFromOtherOn10_10() { o10_10.returns10_11Introduced10_11() // expected-error {{'returns10_11Introduced10_11()' is only available on OS X 10.11 or newer}} // expected-note@-1 {{guard with version check}} - let o10_11 = OtherIntroduced10_11() // expected-error {{'OtherIntroduced10_11' is only available on OS X 10.11 or newer}} + let _ = OtherIntroduced10_11() // expected-error {{'OtherIntroduced10_11' is only available on OS X 10.11 or newer}} // expected-note@-1 {{guard with version check}} o10_10.extensionMethodOnOtherIntroduced10_10AvailableOn10_11() // expected-error {{'extensionMethodOnOtherIntroduced10_10AvailableOn10_11()' is only available on OS X 10.11 or newer}} diff --git a/test/Sema/diag_metatype_cast_to_reference_no_objc.swift b/test/Sema/diag_metatype_cast_to_reference_no_objc.swift index b8ac5ebc56334..995ad8ddbd55e 100644 --- a/test/Sema/diag_metatype_cast_to_reference_no_objc.swift +++ b/test/Sema/diag_metatype_cast_to_reference_no_objc.swift @@ -3,6 +3,6 @@ class C {} func test(c: AnyClass) { - let obj: AnyObject = c // expected-error {{type 'AnyClass' does not conform to protocol 'AnyObject'}} - let obj2: AnyObject = C.self // expected-error {{type 'C.Type' does not conform to protocol 'AnyObject'}} + let _: AnyObject = c // expected-error {{type 'AnyClass' does not conform to protocol 'AnyObject'}} + let _: AnyObject = C.self // expected-error {{type 'C.Type' does not conform to protocol 'AnyObject'}} } diff --git a/test/Sema/diag_self_assign.swift b/test/Sema/diag_self_assign.swift index 500626cbf53df..77a1aebdf6e52 100644 --- a/test/Sema/diag_self_assign.swift +++ b/test/Sema/diag_self_assign.swift @@ -95,7 +95,7 @@ class SA_Deep1 { var aFoo = Foo() func test() { - var aBar = Bar() + let aBar = Bar() aBar.aFoo = Foo() aBar.aFoo.aThing = self.aFoo.aThing // no-error } diff --git a/test/Sema/diag_values_of_module_type.swift b/test/Sema/diag_values_of_module_type.swift index bcd0f04f9d3b1..6db2bc929a04f 100644 --- a/test/Sema/diag_values_of_module_type.swift +++ b/test/Sema/diag_values_of_module_type.swift @@ -36,30 +36,30 @@ protocol GoodProtocol1 : diag_values_of_module_type_foo.SomeProtocol { typealias GoodTypealias1 = Swift.Int func goodTest1() { - var a1 = Swift.Int(zero) - - var b1 : diag_values_of_module_type_foo.SomeClass - var b2 : diag_values_of_module_type_foo.SomeClass.NestedClass - var b3 : diag_values_of_module_type_foo.SomeStruct - var b4 : diag_values_of_module_type_foo.SomeEnum - var b5 : diag_values_of_module_type_foo.SomeExistential - var b6 : diag_values_of_module_type_foo.SomeTypealias - - var c1 = diag_values_of_module_type_foo.SomeClass() - var c2 = diag_values_of_module_type_foo.SomeClass.NestedClass() - var c3 = diag_values_of_module_type_foo.SomeClass.staticFunc1 - var c4 = diag_values_of_module_type_foo.SomeClass.staticFunc1() - var c5 = diag_values_of_module_type_foo.SomeClass.staticVar1 - var c6 = diag_values_of_module_type_foo.SomeStruct() - var c7 = diag_values_of_module_type_foo.SomeEnum.Foo + var _ = Swift.Int(zero) + + var _ : diag_values_of_module_type_foo.SomeClass + var _ : diag_values_of_module_type_foo.SomeClass.NestedClass + var _ : diag_values_of_module_type_foo.SomeStruct + var _ : diag_values_of_module_type_foo.SomeEnum + var _ : diag_values_of_module_type_foo.SomeExistential + var _ : diag_values_of_module_type_foo.SomeTypealias + + var _ = diag_values_of_module_type_foo.SomeClass() + var _ = diag_values_of_module_type_foo.SomeClass.NestedClass() + var _ = diag_values_of_module_type_foo.SomeClass.staticFunc1 + var _ = diag_values_of_module_type_foo.SomeClass.staticFunc1() + var _ = diag_values_of_module_type_foo.SomeClass.staticVar1 + var _ = diag_values_of_module_type_foo.SomeStruct() + var _ = diag_values_of_module_type_foo.SomeEnum.Foo // Can not default-construct a protocol. - // var c8 = diag_values_of_module_type_foo.SomeExistential() - var c9 = diag_values_of_module_type_foo.SomeTypealias() + // var _ = diag_values_of_module_type_foo.SomeExistential() + var _ = diag_values_of_module_type_foo.SomeTypealias() - var d1 = diag_values_of_module_type_foo.someGlobal + var _ = diag_values_of_module_type_foo.someGlobal diag_values_of_module_type_foo.someGlobal = 42 - var e1 = diag_values_of_module_type_foo.someFunc + var _ = diag_values_of_module_type_foo.someFunc diag_values_of_module_type_foo.someFunc() } @@ -87,10 +87,12 @@ class BadClass1 { func badTest1() { var x = Swift // expected-error {{expected module member name after module name}} x = Swift // expected-error {{expected module member name after module name}} + _ = x } func badTest2() { var x = 0 x = Swift // expected-error {{expected module member name after module name}} expected-error {{cannot assign a value of type 'module' to a value of type 'Int'}} + _ = x } func badTest3() { var x = Swift. // expected-error {{postfix '.' is reserved}} expected-error {{expected member name following '.'}} @@ -103,10 +105,10 @@ func badTest5() { } func badTest6() { // FIXME: should be only a single diagnostic. - var a = { () -> Int in - var x = Swift // expected-error 2{{expected module member name after module name}} + var _ = { () -> Int in + var _ = Swift // expected-error 2{{expected module member name after module name}} return 42 }() - var b = { Swift }() // expected-error {{expected module member name after module name}} - var c = { { Swift }() }() // expected-error {{expected module member name after module name}} + var _ = { Swift }() // expected-error {{expected module member name after module name}} + var _ = { { Swift }() }() // expected-error {{expected module member name after module name}} } diff --git a/test/Sema/immutability.swift b/test/Sema/immutability.swift index 81c6224fca8bf..fc37d2240b346 100644 --- a/test/Sema/immutability.swift +++ b/test/Sema/immutability.swift @@ -304,7 +304,7 @@ protocol SubscriptNoGetter { } func testSubscriptNoGetter(let iis: SubscriptNoGetter) { - var i: Int = iis[17] + var _: Int = iis[17] } func testSelectorStyleArguments1(var x: Int, var bar y: Int) { diff --git a/test/TypeCoercion/integer_literals.swift b/test/TypeCoercion/integer_literals.swift index 7bba248ebc10b..856c4193de251 100644 --- a/test/TypeCoercion/integer_literals.swift +++ b/test/TypeCoercion/integer_literals.swift @@ -4,17 +4,17 @@ typealias IntegerLiteralType = Int32 // Simple coercion of literals. func simple() { - var x1 : Int8 = 1 - var x2 : Int16 = 1 + var _ : Int8 = 1 + var _ : Int16 = 1 } // Coercion of literals through operators. func operators(x1: Int8) { - var x2 : Int8 = 1 + 2 - var x3 : Int8 = 1 + x1 - var x4 : Int8 = x2 + 1 - var x5 : Int8 = x1 + x2 + 1 + 4 + x3 + 5 + let x2 : Int8 = 1 + 2 + let x3 : Int8 = 1 + x1 + var _ : Int8 = x2 + 1 + var _ : Int8 = x1 + x2 + 1 + 4 + x3 + 5 } // Check coercion failure due to overflow. diff --git a/test/TypeCoercion/interpolation.swift b/test/TypeCoercion/interpolation.swift index 882dce5474ab3..80c416111d6f2 100644 --- a/test/TypeCoercion/interpolation.swift +++ b/test/TypeCoercion/interpolation.swift @@ -5,7 +5,7 @@ func simple_ret(s: String, i: Int) -> String { } func in_context(s: String, i: Int) -> String { - var h = "\(s) = \(i)" + let h = "\(s) = \(i)" return h } diff --git a/test/TypeCoercion/overload_member.swift b/test/TypeCoercion/overload_member.swift index d753931a89e3a..cf081172b54d0 100644 --- a/test/TypeCoercion/overload_member.swift +++ b/test/TypeCoercion/overload_member.swift @@ -27,9 +27,11 @@ class A { func test_method_overload(a: A, x: X, y: Y) { var x1 = a.f(x: x) x1 = x + _ = x1 var y1 = a.f(y: y) y1 = y + _ = y1 } func test_method_overload_coerce(a: A, inout x: X, inout y: Y, z: Z) { @@ -39,16 +41,18 @@ func test_method_overload_coerce(a: A, inout x: X, inout y: Y, z: Z) { } func test_method_value_coerce(a: A) { - var fp1 : (X) -> X = a.f; - var fp2 : (A) -> (X) -> X = A.f; + var _ : (X) -> X = a.f; + var _ : (A) -> (X) -> X = A.f; } func test_static_method_overload(a: A, x: X, y: Y) { var x1 = A.sf(x: x) x1 = x + _ = x1 var y1 = A.sf(y: y) y1 = y + _ = y1 } func test_static_method_overload_coerce(a: A, inout x: X, inout y: Y, z: Z) { @@ -58,8 +62,8 @@ func test_static_method_overload_coerce(a: A, inout x: X, inout y: Y, z: Z) { } func test_static_method_value_coerce(a: A) { - var fp1 : (X) -> X = A.sf; - var fp2 : (Y) -> Y = A.sf; + var _ : (X) -> X = A.sf; + var _ : (Y) -> Y = A.sf; } func test_mixed_overload(a: A, x: X, y: Y) { @@ -79,27 +83,33 @@ func test_mixed_overload_coerce(a: A, inout x: X, y: Y, z: Z) { a.mixed2(z: z) var y1 = A.mixed2(z: z) y1 = y + _ = y1 x = a.mixed2(z: z) } func test_mixed_method_value_coerce(a: A) { - var fp1 : (X) -> X = a.mixed; - var fp2 : (Y) -> Y = A.mixed; - var fp3 : (Y) -> Y = a.mixed; // expected-error{{'Y' is not a subtype of 'X'}} - var fp4 : (A) -> (X) -> X = A.mixed; + var _ : (X) -> X = a.mixed; + var _ : (Y) -> Y = A.mixed; + var _ : (Y) -> Y = a.mixed; // expected-error{{'Y' is not a subtype of 'X'}} + var _ : (A) -> (X) -> X = A.mixed; } extension A { func test_method_overload(x x: X, y: Y) { var x1 = self.f(x: x) x1 = x + _ = x1 var x2 = f(x: x) x2 = x + _ = x2 + var y1 = self.f(y: y) y1 = y + _ = y1 var y2 = f(y: y) y2 = y + _ = y2 } func test_method_overload_coerce(inout x x: X, inout y: Y, z: Z) { @@ -109,9 +119,9 @@ extension A { } func test_method_value_coerce() { - var fp1 : (X) -> X = f; - var fp2 : (A) -> (X) -> X = A.f; - var fp3 : (A) -> (X) -> X = A.f; + var _ : (X) -> X = f; + var _ : (A) -> (X) -> X = A.f; + var _ : (A) -> (X) -> X = A.f; } func test_mixed_overload_coerce(inout x x: X, y: Y, z: Z) { @@ -120,18 +130,20 @@ extension A { } func test_mixed_method_value_coerce() { - var fp1 : (X) -> X = mixed; - var fp2 : (Y) -> Y = mixed; // expected-error{{'Y' is not a subtype of 'X'}} - var fp3 : (Y) -> Y = mixed; // expected-error{{'Y' is not a subtype of 'X'}} - var fp4 : (A) -> (X) -> X = A.mixed; + var _ : (X) -> X = mixed; + var _ : (Y) -> Y = mixed; // expected-error{{'Y' is not a subtype of 'X'}} + var _ : (Y) -> Y = mixed; // expected-error{{'Y' is not a subtype of 'X'}} + var _ : (A) -> (X) -> X = A.mixed; } class func test_method_overload_static(x x: X, y: Y, z: Z) { var x1 = sf(x: x) x1 = x + _ = x1 var y1 = sf(y: y) y1 = y + _ = y1 } class func test_method_overload_coerce_static(inout x x: X, inout y: Y, z: Z) { @@ -141,8 +153,8 @@ extension A { } class func test_method_value_coerce_static() { - var fp1 : (X) -> X = sf; - var fp2 : (Y) -> Y = sf; + var _ : (X) -> X = sf + var _ : (Y) -> Y = sf } class func test_mixed_overload_static(a a: A, x: X, y: Y) { @@ -156,11 +168,12 @@ extension A { class func test_mixed_overload_coerce_static(y y: Y, z: Z) { var y1 = mixed2(z: z) y1 = y + _ = y1 } class func test_mixed_method_value_coerce_static() { - var fp1 : (Y) -> Y = mixed; - var fp2 : (A) -> (X) -> X = mixed; + var _ : (Y) -> Y = mixed; + var _ : (A) -> (X) -> X = mixed; } } @@ -170,7 +183,7 @@ struct WeirdIvarLookupBehavior { var clams : Y func f() { - var y : Y = clams + var _ : Y = clams } static func static_f() { diff --git a/test/TypeCoercion/overload_noncall.swift b/test/TypeCoercion/overload_noncall.swift index e19732fc5201d..61c957bd8fce5 100644 --- a/test/TypeCoercion/overload_noncall.swift +++ b/test/TypeCoercion/overload_noncall.swift @@ -62,8 +62,9 @@ func lvalue_or_rvalue(x: X) -> Y { } func test_lvalue_or_rvalue() { var x : X; var y : Y; - var x1 = lvalue_or_rvalue(&x) + let x1 = lvalue_or_rvalue(&x) x = x1 - var y1 = lvalue_or_rvalue(x) + let y1 = lvalue_or_rvalue(x) y = y1 + _ = y } diff --git a/test/TypeCoercion/protocols.swift b/test/TypeCoercion/protocols.swift index 793a1a47ac340..7013593b2eaf3 100644 --- a/test/TypeCoercion/protocols.swift +++ b/test/TypeCoercion/protocols.swift @@ -48,6 +48,7 @@ func testPrintableCoercion(ip1: IsPrintable1, p = inp1 // expected-error{{cannot assign a value of type 'IsNotPrintable1' to a value of type 'MyPrintable'}} p = inp2 // expected-error{{cannot assign a value of type 'IsNotPrintable2' to a value of type 'MyPrintable'}} p = op // expected-error{{cannot assign a value of type 'OtherPrintable' to a value of type 'MyPrintable'}} + _ = p } func testTitledCoercion(ip1: IsPrintable1, book: Book, lackey: Lackey, @@ -58,6 +59,7 @@ func testTitledCoercion(ip1: IsPrintable1, book: Book, lackey: Lackey, t = lackey t = number // expected-error{{cannot assign a value of type 'Number' to a value of type 'Titled'}} t = ip2 // expected-error{{cannot assign a value of type 'IsPrintable2' to a value of type 'Titled'}} + _ = t } @@ -164,8 +166,8 @@ func doREPLPrint(p: MyREPLPrintable) { } func testREPLPrintable() { - var i : Int - var rp : MyREPLPrintable = i + let i : Int = 1 + var _ : MyREPLPrintable = i doREPLPrint(i) doREPLPrint(1) doREPLPrint("foo") diff --git a/test/TypeCoercion/return_coercion.swift b/test/TypeCoercion/return_coercion.swift index 35589f6e46579..fc6cdb1d52398 100644 --- a/test/TypeCoercion/return_coercion.swift +++ b/test/TypeCoercion/return_coercion.swift @@ -5,6 +5,6 @@ func f2() -> (Int, Int) { return (1, 2) } func f2() -> (Float, Float) { return (1, 2) } func g() { - var x1 : (a : Int, b : Int) = f1() - var x2 : (a : Int, b : Int) = f2() + var _ : (a : Int, b : Int) = f1() + var _ : (a : Int, b : Int) = f2() } diff --git a/test/TypeCoercion/subtyping.swift b/test/TypeCoercion/subtyping.swift index 64565e6a58fec..7f83a89625d68 100644 --- a/test/TypeCoercion/subtyping.swift +++ b/test/TypeCoercion/subtyping.swift @@ -47,9 +47,10 @@ func fp_gen_to_p(_: () -> FormattedPrintable) -> CustomStringConvertible {} func nonTrivialNested() { // FIXME: closures make ABI conversions explicit. rdar://problem/19517003 var f1 : (_ : () -> CustomStringConvertible) -> CustomStringConvertible = { p_gen_to_fp($0) } - var f2 : (_ : () -> CustomStringConvertible) -> FormattedPrintable = p_gen_to_fp - var f3 : (_ : () -> FormattedPrintable) -> CustomStringConvertible = fp_gen_to_p + let f2 : (_ : () -> CustomStringConvertible) -> FormattedPrintable = p_gen_to_fp + let f3 : (_ : () -> FormattedPrintable) -> CustomStringConvertible = fp_gen_to_p f1 = { f2($0) } // okay f1 = f3 // expected-error{{annot assign a value of type '(() -> FormattedPrintable) -> CustomStringConvertible' to a value of type '(() -> CustomStringConvertible) -> CustomStringConvertible'}} + let _ = f1 } diff --git a/test/TypeCoercion/unknowable.swift b/test/TypeCoercion/unknowable.swift index 2240763847e57..d5ae3e6336784 100644 --- a/test/TypeCoercion/unknowable.swift +++ b/test/TypeCoercion/unknowable.swift @@ -4,7 +4,7 @@ // Refer to members of literals //===----------------------------------------------------------------------===// func testLiteralMembers() { - var x = 0.value + var _ = 0.value Int(0.value) } @@ -25,7 +25,7 @@ func testLiteralOverloadinovlLitB() { func literalOverloadSameReturn(i: Int) -> Int {} func literalOverloadSameReturn(i: Int32) -> Int {} func literalOverload2() { - var x : Int = literalOverloadSameReturn(literalOverloadSameReturn(1)) + var _ : Int = literalOverloadSameReturn(literalOverloadSameReturn(1)) } //===----------------------------------------------------------------------===// diff --git a/test/expr/capture/nested_class.swift b/test/expr/capture/nested_class.swift index a53bf2fd78bca..31589ee3e4c94 100644 --- a/test/expr/capture/nested_class.swift +++ b/test/expr/capture/nested_class.swift @@ -7,4 +7,6 @@ func capture_nested_class() { return a // FIXME: should probably be disallowed } } + a = 1 + _ = a } diff --git a/test/expr/capture/order.swift b/test/expr/capture/order.swift index 38e6d1fcf9ccb..b4ee8cc8c0b81 100644 --- a/test/expr/capture/order.swift +++ b/test/expr/capture/order.swift @@ -6,6 +6,7 @@ func makeIncrementor(amount: Int) -> () -> Int { return currentTotal // note: redundant diagnostic suppressed } var currentTotal = 0 // expected-note{{'currentTotal' declared here}} + currentTotal = 1; _ = currentTotal return incrementor } diff --git a/test/expr/cast/CoreFoundation.swift b/test/expr/cast/CoreFoundation.swift index 3208087757abe..64ed1b70ed247 100644 --- a/test/expr/cast/CoreFoundation.swift +++ b/test/expr/cast/CoreFoundation.swift @@ -8,6 +8,7 @@ import Foundation func testCFToObjC(cfStr: CFString, cfMutableStr: CFMutableString) { var nsStr: NSString = cfStr nsStr = cfMutableStr + _ = nsStr var nsMutableStr: NSMutableString = cfMutableStr nsMutableStr = cfStr // expected-error{{cannot assign a value of type 'CFString' to a value of type 'NSMutableString'}} @@ -30,6 +31,7 @@ func testObjCToCF(nsStr: NSString, nsMutableStr: NSMutableString) { func testCFToNative(cfStr: CFString, cfMutableStr: CFMutableString) { var str = cfStr as String str = cfMutableStr as String + _ = str } func testNativeToCF(str: String) { @@ -42,31 +44,33 @@ func testCFToAnyObject(cfStr: CFString, cfMutableStr: CFMutableString, var anyObject: AnyObject = cfStr anyObject = cfMutableStr anyObject = cfTree + _ = anyObject } func testAnyObjectToCF(anyObject: AnyObject) { var cfStr: CFString = anyObject as! CFString - var cfMutableStr: CFMutableString = anyObject as! CFMutableString - var cfTree: CFTree = anyObject as! CFTree + var _: CFMutableString = anyObject as! CFMutableString + var _: CFTree = anyObject as! CFTree // No implicit conversions. cfStr = anyObject // expected-error{{'AnyObject' is not convertible to 'CFString'; did you mean to use 'as!' to force downcast?}} + _ = cfStr } func testUncheckableCasts(anyObject: AnyObject, nsObject: NSObject, anyObjectType: AnyObject.Type, nsObjectType: NSObject.Type) { - if let cfStr = anyObject as? CFString { } // expected-error{{conditional downcast to CoreFoundation type 'CFString' will always succeed}} - if let cfStr = nsObject as? CFString { } // expected-error{{conditional downcast to CoreFoundation type 'CFString' will always succeed}} + if let _ = anyObject as? CFString { } // expected-error{{conditional downcast to CoreFoundation type 'CFString' will always succeed}} + if let _ = nsObject as? CFString { } // expected-error{{conditional downcast to CoreFoundation type 'CFString' will always succeed}} - if let cfTree = anyObject as? CFTree { } // expected-error{{conditional downcast to CoreFoundation type 'CFTree' will always succeed}} - if let cfTree = nsObject as? CFTree { } // expected-error{{will always succeed}} + if let _ = anyObject as? CFTree { } // expected-error{{conditional downcast to CoreFoundation type 'CFTree' will always succeed}} + if let _ = nsObject as? CFTree { } // expected-error{{will always succeed}} - if let cfStrType = anyObjectType as? CFString.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFString.Type' will always succeed}} - if let cfStrType = nsObjectType as? CFString.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFString.Type' will always succeed}} + if let _ = anyObjectType as? CFString.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFString.Type' will always succeed}} + if let _ = nsObjectType as? CFString.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFString.Type' will always succeed}} - if let cfTreeType = anyObjectType as? CFTree.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFTree.Type' will always succeed}} - if let cfTreeType = nsObjectType as? CFTree.Type { } // expected-error{{will always succeed}} + if let _ = anyObjectType as? CFTree.Type { } // expected-error{{conditional downcast to CoreFoundation type 'CFTree.Type' will always succeed}} + if let _ = nsObjectType as? CFTree.Type { } // expected-error{{will always succeed}} } func testCFConvWithIUO(x: CFString!, y: NSString!) { diff --git a/test/expr/cast/array_downcast.swift b/test/expr/cast/array_downcast.swift index 16781d3745fa7..c8559ce00d222 100644 --- a/test/expr/cast/array_downcast.swift +++ b/test/expr/cast/array_downcast.swift @@ -69,15 +69,17 @@ func testBridgedDowncastAnyObject(arr: [AnyObject], arrOpt: [AnyObject]?, if let bArr = arrIUO as? [B] { b = bArr[0] } + _ = b } func testBridgedIsAnyObject(arr: [AnyObject], arrOpt: [AnyObject]?, arrIUO: [AnyObject]!) -> Bool { - var b = B() + let b = B() if arr is [B] { return arr is [B] } if arrOpt is [B] { return arrOpt is [B] } if arrIUO is [B] { return arrIUO is [B] } + _ = b return false } diff --git a/test/expr/cast/array_downcast_Foundation.swift b/test/expr/cast/array_downcast_Foundation.swift index 4cf87434d29b3..c8fd764e9896d 100644 --- a/test/expr/cast/array_downcast_Foundation.swift +++ b/test/expr/cast/array_downcast_Foundation.swift @@ -29,8 +29,8 @@ func testArrayDowncast(arr: [AnyObject], arrImplicit: [AnyObject]!) { } func testDowncastNSArrayToArray(nsarray: NSArray) { - var nsstrArr1 = nsarray as! [NSString] - var strArr1 = nsarray as! [String] + var _ = nsarray as! [NSString] + var _ = nsarray as! [String] } // CHECK-LABEL: testDowncastOptionalObject diff --git a/test/expr/cast/as_coerce.swift b/test/expr/cast/as_coerce.swift index 9f093f246730c..4eae382f53e9d 100644 --- a/test/expr/cast/as_coerce.swift +++ b/test/expr/cast/as_coerce.swift @@ -16,10 +16,10 @@ func doFoo() {} func test_coercion(a: A, b: B) { // Coercion to a protocol type - var x = a as P1 + let x = a as P1 x.foo() // Coercion to a superclass type - var y = b as A + let y = b as A y.foo() } @@ -29,7 +29,7 @@ class D : C { } func prefer_coercion(inout c: C) { - var d = c as! D + let d = c as! D c = d } diff --git a/test/expr/cast/bridged.swift b/test/expr/cast/bridged.swift index e427e5423e87f..c2460a2359c99 100644 --- a/test/expr/cast/bridged.swift +++ b/test/expr/cast/bridged.swift @@ -39,7 +39,7 @@ struct BridgedStruct : _ObjectiveCBridgeable { func testBridgeDowncast(obj: AnyObject, objOpt: AnyObject?, objImplicitOpt: AnyObject!) -> BridgedStruct? { - var s1Opt = obj as? BridgedStruct + let s1Opt = obj as? BridgedStruct var s2Opt = objOpt as? BridgedStruct var s3Opt = objImplicitOpt as? BridgedStruct @@ -48,6 +48,7 @@ func testBridgeDowncast(obj: AnyObject, objOpt: AnyObject?, s2Opt = s1Opt s2Opt = s3Opt s3Opt = s1Opt + _ = s2Opt return s1Opt } @@ -62,16 +63,16 @@ func testBridgeIsa(obj: AnyObject, objOpt: AnyObject?, func testBridgeDowncastSuperclass(obj: NSObject, objOpt: NSObject?, objImplicitOpt: NSObject!) -> BridgedStruct? { - var s1Opt = obj as? BridgedStruct - var s2Opt = objOpt as? BridgedStruct - var s3Opt = objImplicitOpt as? BridgedStruct + var _ = obj as? BridgedStruct + var _ = objOpt as? BridgedStruct + var _ = objImplicitOpt as? BridgedStruct } func testBridgeDowncastExact(obj: BridgedClass, objOpt: BridgedClass?, objImplicitOpt: BridgedClass!) -> BridgedStruct? { - var s1Opt = obj as? BridgedStruct // expected-warning{{conditional cast from 'BridgedClass' to 'BridgedStruct' always succeeds}} - var s2Opt = objOpt as? BridgedStruct - var s3Opt = objImplicitOpt as? BridgedStruct // expected-warning{{conditional cast from 'BridgedClass!' to 'BridgedStruct' always succeeds}} + var _ = obj as? BridgedStruct // expected-warning{{conditional cast from 'BridgedClass' to 'BridgedStruct' always succeeds}} + var _ = objOpt as? BridgedStruct + var _ = objImplicitOpt as? BridgedStruct // expected-warning{{conditional cast from 'BridgedClass!' to 'BridgedStruct' always succeeds}} } func testExplicitBridging(var object: BridgedClass, var value: BridgedStruct) { @@ -80,6 +81,6 @@ func testExplicitBridging(var object: BridgedClass, var value: BridgedStruct) { } func testBridgingFromSubclass(obj: SubclassOfBridgedClass) { - var s1 = obj as! BridgedStruct // expected-warning{{forced cast from 'SubclassOfBridgedClass' to 'BridgedStruct' always succeeds; did you mean to use 'as'?}} - var s2 = obj as BridgedStruct + var _ = obj as! BridgedStruct // expected-warning{{forced cast from 'SubclassOfBridgedClass' to 'BridgedStruct' always succeeds; did you mean to use 'as'?}} + var _ = obj as BridgedStruct } diff --git a/test/expr/cast/dictionary_bridge.swift b/test/expr/cast/dictionary_bridge.swift index 8ef0fd5967c18..a5a48cf251a52 100644 --- a/test/expr/cast/dictionary_bridge.swift +++ b/test/expr/cast/dictionary_bridge.swift @@ -86,20 +86,22 @@ func testUpcastBridge() { dictDO = dictBB // expected-error{{cannot assign a value of type 'Dictionary' to a value of type 'Dictionary'}} dictOD = dictBB // expected-error{{cannot assign a value of type 'Dictionary' to a value of type 'Dictionary'}} dictDD = dictBB // expected-error{{cannot assign a value of type 'Dictionary' to a value of type 'Dictionary'}} + + _ = dictDD; _ = dictDO; _ = dictOD; _ = dictOO; _ = dictOR; _ = dictOR; _ = dictRR; _ = dictRO } func testDowncastBridge() { - var dictRR = Dictionary() - var dictRO = Dictionary() - var dictOR = Dictionary() - var dictOO = Dictionary() - var dictOD = Dictionary() - var dictDO = Dictionary() - var dictDD = Dictionary() - - var dictBB = Dictionary() - var dictBO = Dictionary() - var dictOB = Dictionary() + let dictRR = Dictionary() + let dictRO = Dictionary() + let _ = Dictionary() + let _ = Dictionary() + let _ = Dictionary() + let dictDO = Dictionary() + let _ = Dictionary() + + let _ = Dictionary() + let dictBO = Dictionary() + let dictOB = Dictionary() // Downcast to bridged value types. dictRR as! Dictionary diff --git a/test/expr/cast/optional.swift b/test/expr/cast/optional.swift index f052c1ccd9a58..59df129df73c3 100644 --- a/test/expr/cast/optional.swift +++ b/test/expr/cast/optional.swift @@ -15,10 +15,10 @@ func f1(i: Int?, ii: Int??, a: [Base]?, d: [Base : Base]?) { } func implicitCastOfLiteralToOptional() { - var optinalInt: Int? = 0 - var optionalString: String? = "" - var optionalArray: [Int] = [] - var optionalDictionary: [Int : Int]? = [:] - var optionalSet: Set = [] + var _: Int? = 0 + var _: String? = "" + var _: [Int] = [] + var _: [Int : Int]? = [:] + var _: Set = [] } diff --git a/test/expr/cast/set_bridge.swift b/test/expr/cast/set_bridge.swift index 476c01c5f6d00..ce6e8ca6ef291 100644 --- a/test/expr/cast/set_bridge.swift +++ b/test/expr/cast/set_bridge.swift @@ -53,21 +53,22 @@ func testUpcastBridge() { var setB = Set() // Upcast to object types. - setR = setB - setO = setB + setR = setB; _ = setR + setO = setB; _ = setO // Upcast object to bridged type setB = setO // expected-error{{cannot assign a value of type 'Set' to a value of type 'Set'}} // Failed upcast setD = setB // expected-error{{cannot assign a value of type 'Set' to a value of type 'Set'}} + _ = setD } func testForcedDowncastBridge() { - var setR = Set() - var setO = Set() - var setD = Set() - var setB = Set() + let setR = Set() + let setO = Set() + let setD = Set() + let setB = Set() setR as! Set setO as! Set diff --git a/test/expr/closure/basic.swift b/test/expr/closure/basic.swift index 5b081bd49be9f..65b8bba532d96 100644 --- a/test/expr/closure/basic.swift +++ b/test/expr/closure/basic.swift @@ -31,12 +31,12 @@ func variadic() { // Closures with attributes in the parameter list. func attrs() { - var f1 = {(inout z: Int) -> Int in z } + var _ = {(inout z: Int) -> Int in z } } // Closures with argument and parameter names. func argAndParamNames() -> Int { - var f1: (x: Int, y: Int) -> Int = { (a x, b y) in x + y } + let f1: (x: Int, y: Int) -> Int = { (a x, b y) in x + y } f1(x: 1, y: 2) return f1(x: 1, y: 2) } diff --git a/test/expr/closure/default_args.swift b/test/expr/closure/default_args.swift index e45c448245827..16691de166a93 100644 --- a/test/expr/closure/default_args.swift +++ b/test/expr/closure/default_args.swift @@ -7,7 +7,7 @@ func simple_default_args() { func func_default_args() { func has_default_args(x x: Int = 1) -> Int { return x+1 } - var f1 : (Int) -> Int = has_default_args // okay - var f2 : () -> Int = has_default_args // expected-error{{(x: Int) -> Int' is not convertible to '() -> Int}} + var _ : (Int) -> Int = has_default_args // okay + var _ : () -> Int = has_default_args // expected-error{{(x: Int) -> Int' is not convertible to '() -> Int}} } diff --git a/test/expr/closure/inference.swift b/test/expr/closure/inference.swift index 7e0048e9fe1e9..38fb2ab693433 100644 --- a/test/expr/closure/inference.swift +++ b/test/expr/closure/inference.swift @@ -8,9 +8,10 @@ func myMap(array: [T], _ f: (T) -> U) -> [U] {} func testMap(array: [Int]) { var farray = myMap(array, { Float($0) }) - var f : Float = farray[0] - var farray2 = myMap(array, { x in Float(x) }) + var _ : Float = farray[0] + let farray2 = myMap(array, { x in Float(x) }) farray = farray2 + _ = farray } // Infer result type. diff --git a/test/expr/closure/single_expr.swift b/test/expr/closure/single_expr.swift index 6ac3f9ed856bf..b5939112eca0f 100644 --- a/test/expr/closure/single_expr.swift +++ b/test/expr/closure/single_expr.swift @@ -14,7 +14,8 @@ func myMap(array: [T], _ f: (T) -> U) -> [U] {} func testMap(array: [Int]) { var farray = myMap(array, { Float($0) }) - var f : Float = farray[0] - var farray2 = myMap(array, { (x : Int) in Float(x) }) + var _ : Float = farray[0] + let farray2 = myMap(array, { (x : Int) in Float(x) }) farray = farray2 + _ = farray } diff --git a/test/expr/dynamic_lookup.swift b/test/expr/dynamic_lookup.swift index 577c3b87c4d6f..fe6ad97fa8e01 100644 --- a/test/expr/dynamic_lookup.swift +++ b/test/expr/dynamic_lookup.swift @@ -5,5 +5,5 @@ } func testStaticProperty(classObj: AnyObject.Type) { - var x = classObj.staticVar1 + var _ = classObj.staticVar1 } diff --git a/test/expr/expressions.swift b/test/expr/expressions.swift index 3e979fcddc567..634e61426c5d1 100644 --- a/test/expr/expressions.swift +++ b/test/expr/expressions.swift @@ -161,13 +161,13 @@ func test4() -> ((arg1: Int, arg2: Int) -> Int) { } func test5() { - var a: (Int, Int) + let a: (Int, Int) = (1,2) var - b: ((Int) -> Int, Int) = a // expected-error {{'Int' is not convertible to '(Int) -> Int'}} + _: ((Int) -> Int, Int) = a // expected-error {{'Int' is not convertible to '(Int) -> Int'}} - var c: (a: Int, b: Int) - var d: (b: Int, a: Int) = c // Ok, reshuffle tuple. + let c: (a: Int, b: Int) = (1,2) + let _: (b: Int, a: Int) = c // Ok, reshuffle tuple. } @@ -210,10 +210,10 @@ func test_unary3() { } func test_as_1() { - var x: Int + var _: Int } func test_as_2() { - var x: Int + let x: Int = 1 x as [] // expected-error {{expected element type}} } @@ -239,10 +239,10 @@ func test_lambda2() { } func test_floating_point() { - var x = 0.0 - var y = 100.1 - var x1: Float = 0.0 - var x2: Double = 0.0 + var _ = 0.0 + var _ = 100.1 + var _: Float = 0.0 + var _: Double = 0.0 } func test_nonassoc(x: Int, y: Int) -> Bool { @@ -312,10 +312,10 @@ markUsed((tupleelemvar, tupleelemvar).1) func int_literals() { // Fits exactly in 64-bits - rdar://11297273 - var a = 1239123123123123 + var _ = 1239123123123123 // Overly large integer. // FIXME: Should warn about it. - var b = 123912312312312312312 + var _ = 123912312312312312312 } @@ -540,8 +540,8 @@ func..<(x: Double, y: Double) -> Double { } func iterators() { - var a = 0..<42 - var b = 0.0..<42.0 + var _ = 0..<42 + var _ = 0.0..<42.0 } //===----------------------------------------------------------------------===// @@ -549,9 +549,9 @@ func iterators() { //===----------------------------------------------------------------------===// func magic_literals() { - var x = __FILE__ - var y = __LINE__ + __COLUMN__ - var z: UInt8 = __LINE__ + __COLUMN__ + _ = __FILE__ + _ = __LINE__ + __COLUMN__ + var _: UInt8 = __LINE__ + __COLUMN__ } //===----------------------------------------------------------------------===// @@ -653,7 +653,7 @@ func testOptionalChaining(a : Int?, b : Int!, c : Int??) { b? // expected-error {{'?' must be followed by a call, member lookup, or subscript}} b?.getMirror() - var y: Int? = c? // expected-error {{'?' must be followed by a call, member lookup, or subscript}} + var _: Int? = c? // expected-error {{'?' must be followed by a call, member lookup, or subscript}} } diff --git a/test/expr/postfix/call/construction.swift b/test/expr/postfix/call/construction.swift index c3729c0bf6e0b..d90f2525b33d4 100644 --- a/test/expr/postfix/call/construction.swift +++ b/test/expr/postfix/call/construction.swift @@ -41,21 +41,21 @@ func getMetatype(m : T.Type) -> T.Type { return m } // Construction from a struct Type value func constructStructMetatypeValue() { - var s = getMetatype(S.self)(i: 5) - var si = getMetatype(S.self) + var _ = getMetatype(S.self)(i: 5) + var _ = getMetatype(S.self) } // Construction from a struct Type value func constructEnumMetatypeValue() { - var e = getMetatype(E.self)(i: 5) + var _ = getMetatype(E.self)(i: 5) } // Construction from a class Type value. func constructClassMetatypeValue() { // Only permitted with a @required constructor. - var c1 = getMetatype(C.self)(d: 1.5) // okay - var c2 = getMetatype(C.self)(i: 5) // expected-error{{constructing an object of class type 'C' with a metatype value must use a 'required' initializer}} - var d1 = getMetatype(D.self)(i: 5) + var _ = getMetatype(C.self)(d: 1.5) // okay + var _ = getMetatype(C.self)(i: 5) // expected-error{{constructing an object of class type 'C' with a metatype value must use a 'required' initializer}} + var _ = getMetatype(D.self)(i: 5) } // -------------------------------------------------------------------------- @@ -83,12 +83,12 @@ protocol P2 { } func constructExistentialValue(pm: P.Type) { - var p1 = pm() - var p2 = P() // expected-error{{constructing an object of protocol type 'P' requires a metatype value}} + var _ = pm() + var _ = P() // expected-error{{constructing an object of protocol type 'P' requires a metatype value}} } typealias P1_and_P2 = protocol func constructExistentialCompositionValue(pm: protocol.Type) { - var p2a = pm(int: 5) - var p2b = P1_and_P2(int: 5) // expected-error{{constructing an object of protocol type 'P1_and_P2' requires a metatype value}} + var _ = pm(int: 5) + var _ = P1_and_P2(int: 5) // expected-error{{constructing an object of protocol type 'P1_and_P2' requires a metatype value}} } diff --git a/test/expr/postfix/dot/init_ref_delegation.swift b/test/expr/postfix/dot/init_ref_delegation.swift index 8c739d1f4a437..96b0808224df1 100644 --- a/test/expr/postfix/dot/init_ref_delegation.swift +++ b/test/expr/postfix/dot/init_ref_delegation.swift @@ -122,7 +122,7 @@ class Z5 : Z4 { // Ill-formed initialization: failure to call initializer. class Z6 { convenience init() { - var f : () -> Z6 = self.init // expected-error{{initializer cannot be referenced without arguments}} + var _ : () -> Z6 = self.init // expected-error{{initializer cannot be referenced without arguments}} } init(other: Z6) { } diff --git a/test/expr/primary/literal/boolean.swift b/test/expr/primary/literal/boolean.swift index 85bc77a7051d3..2ff804871b810 100644 --- a/test/expr/primary/literal/boolean.swift +++ b/test/expr/primary/literal/boolean.swift @@ -3,11 +3,12 @@ func boolLiterals() { var b: Bool = false b = true + _ = b } func defaultBoolLiterals() { - var b = false - var b2: Bool = b + let b = false + var _: Bool = b } struct CustomBool : BooleanLiteralConvertible { @@ -21,5 +22,6 @@ struct CustomBool : BooleanLiteralConvertible { func customBoolLiterals() { var b: CustomBool = false b = true + _ = b }