Skip to content

Removed the ++ and -- operators #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Dec 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
22126b0
Removed the ++ and -- operators
divadretlaw Dec 6, 2015
e178c51
Removed C-style loops and postincrements
divadretlaw Dec 6, 2015
83ebfc2
Replaced 3x 'i = i.successor()' into 'i = i.advancedBy(3)'
divadretlaw Dec 6, 2015
0d89366
More postincrements from stdlib
divadretlaw Dec 6, 2015
91ffddd
Simplfied successor for UnsafePointer
divadretlaw Dec 6, 2015
9513d17
Removed some post-, preincrement/decrements from test
divadretlaw Dec 6, 2015
ab4c05e
Some more
divadretlaw Dec 6, 2015
8071989
Revert to 3 successor statements
divadretlaw Dec 7, 2015
700dabb
Reverted Whitespace changes
divadretlaw Dec 7, 2015
f71dc7f
Reverted more whitespace
divadretlaw Dec 7, 2015
4d80d10
Reverted unnecessary changes
divadretlaw Dec 7, 2015
fc8b73b
Error fixes
divadretlaw Dec 7, 2015
6603014
Error fix
divadretlaw Dec 7, 2015
2417127
Revert statements.swift
divadretlaw Dec 7, 2015
a6457b2
Added removed whitespace
divadretlaw Dec 7, 2015
8ed7ae9
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 7, 2015
54f2679
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 7, 2015
e29f608
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 8, 2015
dacd683
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 8, 2015
4c2a6fc
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 9, 2015
23772b1
Merge remote-tracking branch 'apple/master'
divadretlaw Dec 24, 2015
989da86
Removed Whitespace changes
divadretlaw Dec 24, 2015
bdc3992
Removed whitespace changes
divadretlaw Dec 24, 2015
8e46246
Reverted change
divadretlaw Dec 24, 2015
8849aa3
Cleanup
divadretlaw Dec 24, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/IDE/complete_stmt_controlling_expr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func testCStyleForBodyI5(fooObject: FooStruct) {
func testCStyleForBodyI6(fooObject: FooStruct) {
var localInt = 42
var localFooObject = FooStruct(localInt)
for var i = 0; ; unknown_var++ {
for var i = 0; ; unknown_var += 1 {
#^C_STYLE_FOR_BODY_I_6^#
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/break_continue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func test1() {
func test2() {
print("test2")
var i : Int
for i=0;i<10;i += 1 {
for i in 0..<10 {
if i > 2 {
continue
}
Expand All @@ -25,7 +25,7 @@ func test2() {
func test3() {
print("test3")
var i : Int
for i=0;i<10;i += 1 {
for i in 0..<10 {
if i > 2 {
break
}
Expand Down
Empty file modified test/Parse/recovery.swift
100644 → 100755
Empty file.
11 changes: 6 additions & 5 deletions test/Prototypes/MutableIndexableDict.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct FixedSizedRefArrayOfOptional<T>
init(capacity: Int)
{
buffer = Storage.Buffer(Storage.self, capacity, capacity)
for var i = 0; i < capacity; ++i {
for i in 0..<capacity {
(buffer.baseAddress + i).initialize(.None)
}

Expand Down Expand Up @@ -181,11 +181,12 @@ struct DictionaryIndex<Element> : BidirectionalIndexType {
typealias Index = DictionaryIndex<Element>

func predecessor() -> Index {
var j = self.offset
while --j > 0 {
var j = self.offset - 1
while j > 0 {
if buffer[j] != nil {
return Index(buffer: buffer, offset: j)
}
j -= 1
}
return self
}
Expand Down Expand Up @@ -275,7 +276,7 @@ struct Dictionary<Key: Hashable, Value> : CollectionType, SequenceType {
_buffer[i.offset] = Element(key: key, value: value)

if !found {
++_count
_count += 1
}
}
}
Expand Down Expand Up @@ -360,7 +361,7 @@ struct Dictionary<Key: Hashable, Value> : CollectionType, SequenceType {

// remove the element
_buffer[pos.offset] = .None
--_count
_count -= 1

// If we've put a hole in a chain of contiguous elements, some
// element after the hole may belong where the new hole is.
Expand Down
8 changes: 5 additions & 3 deletions test/SILGen/coverage_while.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ func foo() -> Int32 {
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : (0 + 2)
while (--x > 0) {
if (x % 2 == 0) { continue }
while (x > 0) {
if (x % 2 == 0) { x -= 1; continue }
x -= 1
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 4) - 5)
while (x < 100) {
if (x++ == 10) { break }
if (x == 10) { break }
x += 1
}

// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 6) - 9)
Expand Down
18 changes: 9 additions & 9 deletions test/SILGen/sil_locations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
func ifexpr() -> Int {
var x : Int = 0
if true {
x++;
x += 1;
}
return x
// CHECK-LABEL: sil hidden @_TF13sil_locations6ifexprFT_Si
Expand All @@ -18,9 +18,9 @@ func ifexpr() -> Int {
func ifelseexpr() -> Int {
var x : Int = 0
if true {
x++;
x += 1;
} else {
x--;
x -= 1;
}
return x
// CHECK-LABEL: sil hidden @_TF13sil_locations10ifelseexprFT_Si
Expand Down Expand Up @@ -64,7 +64,7 @@ func ifexpr_rval() -> Int {

// TODO: missing info on the first branch.
func forstmt_empty_cond(i: Int) -> Int {
for var i=0;;++i {}
for var i=0;; i += 1 {}
// CHECK-LABEL: sil hidden @{{.*}}forstmt_empty_cond{{.*}}
// CHECK: apply {{.*}} line:[[@LINE-2]]:13
// CHECK: br [[TRUE_BB:bb[0-9]+]]
Expand Down Expand Up @@ -116,7 +116,7 @@ func multipleReturnsImplicitAndExplicit() {
if x > 10 {
return
}
x++;
x += 1;
// CHECK-LABEL: sil hidden @_TF13sil_locations34multipleReturnsImplicitAndExplicitFT_T_
// CHECK: cond_br
// CHECK: br bb{{[0-9]+}} // {{.*}} line:[[@LINE-5]]:5:return
Expand Down Expand Up @@ -175,13 +175,13 @@ func testIf() {
}

func testFor() {
for (var i:Int = 0; i<10; i++) {
for i in 0..<10 {
var y: Int = 300
y++;
y += 1;
if true {
break
}
y--;
y -= 1;
continue
}

Expand Down Expand Up @@ -352,7 +352,7 @@ func testStringForEachStmt() {
func testForStmt() {
var i = 0
var m = 0
for (i = 0; i < 10; ++i) {
for i in 0..<10 {
m += 1
if m == 15 {
break
Expand Down
6 changes: 3 additions & 3 deletions test/Sema/immutability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func let_decls() {


let e = 42 // expected-note {{change 'let' to 'var' to make it mutable}} {{3-6=var}}
++e // expected-error {{cannot pass immutable value to mutating operator: 'e' is a 'let' constant}}
e += 1 // expected-error {{cannot pass immutable value to mutating operator: 'e' is a 'let' constant}}

// <rdar://problem/16306600> QoI: passing a 'let' value as an inout results in an unfriendly diagnostic
let f = 96 // expected-note {{change 'let' to 'var' to make it mutable}} {{3-6=var}}
Expand Down Expand Up @@ -322,8 +322,8 @@ func testSelectorStyleArguments1(x: Int, bar y: Int) {

func testSelectorStyleArguments2(x: Int,
bar y: Int) {
++x // expected-error {{cannot pass immutable value to mutating operator: 'x' is a 'let' constant}}
++y // expected-error {{cannot pass immutable value to mutating operator: 'y' is a 'let' constant}}
x += 1 // expected-error {{cannot pass immutable value to mutating operator: 'x' is a 'let' constant}}
y += 1 // expected-error {{cannot pass immutable value to mutating operator: 'y' is a 'let' constant}}
}

func invalid_inout(inout var x : Int) { // expected-error {{parameter may not have multiple 'inout', 'var', or 'let' specifiers}} {{26-30=}}
Expand Down
2 changes: 1 addition & 1 deletion test/SourceKit/DocumentStructure/Inputs/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (sd2: Qtys)
}

for i in 0...5 {}
for var i = 0, i2 = 1; i == 0; ++i {}
for var i = 0, i2 = 1; i == 0; i += 1 {}
while let v = o, z = o where v > z {}
repeat {} while v == 0
if let v = o, z = o where v > z {}
Expand Down
4 changes: 2 additions & 2 deletions test/SourceKit/Indexing/index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func test1(cp: ComputedProperty, sub: CC2) {
var x = cp.value
x = cp.readOnly
cp.value = x
++cp.value
cp.value += 1
x = sub[0]
sub[0] = x
++sub[0]
sub[0] += 1
}

struct S2 {
Expand Down
2 changes: 1 addition & 1 deletion validation-test/stdlib/OpenCLSDKOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ tests.test("clSetKernelArgsListAPPLE") {
// Validate our results
//
correct = 0
for(i = 0; i < count; i++)
for i in 0..<count
{
if(results[i] == data[i] * data[i]){
correct += 1
Expand Down