Skip to content

Commit a3af6c8

Browse files
committed
Update existing golden tests to avoid unused assignment warnings
Add variable reads after assignments in test files that focus on other checks (type errors, reassignment errors) so they don't incidentally trigger the new unused assignment check. https://claude.ai/code/session_01CwKU5QxyLPjEf5m7ybdmQJ
1 parent 36aec29 commit a3af6c8

File tree

5 files changed

+35
-69
lines changed

5 files changed

+35
-69
lines changed

src/test_files/check/assign_add.gdn

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ public fun foo() {
33
x += 1 // OK
44

55
x += "" // bad
6+
let _a = x
67

78
let y = "abc"
89
y -= 2 // bad
10+
let _b = y
911
}
1012

1113
// args: check
@@ -16,26 +18,14 @@ public fun foo() {
1618
// 3| x += 1 // OK
1719
// 4|
1820
// 5| x += "" // bad
19-
// 6| ^^
20-
// 7| let y = "abc"
21+
// | ^^
22+
// 6| let _a = x
2123
//
2224
// Error: `-=` can only be used with `Int` variables, but got `String`.
23-
// --| src/test_files/check/assign_add.gdn:8:5
24-
// 7| let y = "abc"
25-
// 8| y -= 2 // bad
26-
// 9| } ^
27-
//
28-
// Warning: `x` is not read after this assignment.
29-
// --| src/test_files/check/assign_add.gdn:5:5
30-
// 3| x += 1 // OK
31-
// 4|
32-
// 5| x += "" // bad
33-
// 6| ^^^^^^^
34-
// 7| let y = "abc"
35-
//
36-
// Warning: `y` is not read after this assignment.
37-
// --| src/test_files/check/assign_add.gdn:8:5
38-
// 7| let y = "abc"
39-
// 8| y -= 2 // bad
40-
// 9| } ^^^^^^
25+
// --| src/test_files/check/assign_add.gdn:9:5
26+
// 8| let y = "abc"
27+
// 9| y -= 2 // bad
28+
// | ^
29+
// 10| let _b = y
30+
// 11| }
4131

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
public fun foo(): Unit {
22
let i = 0
33
i = 2
4+
let _ = i
45
}
56

67
// args: check
7-
// expected exit status: 1
8-
// expected stdout:
9-
// Warning: `i` is not read after this assignment.
10-
// -| src/test_files/check/assign_returns_unit.gdn:3:5
11-
// 1| public fun foo(): Unit {
12-
// 2| let i = 0
13-
// 3| i = 2
14-
// 4| } ^^^^^
15-
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
public fun foo() {
22
bar = 1
3+
let _ = bar
34
}
45

56
public fun bar() {}
@@ -11,17 +12,15 @@ public fun bar() {}
1112
// -| src/test_files/check/assign_toplevel_fun_name.gdn:2:3
1213
// 1| public fun foo() {
1314
// 2| bar = 1
14-
// 3| } ^^^
15+
// | ^^^
16+
// 3| let _ = bar
17+
// 4| }
1518
//
1619
// Error: Expected `Fun<(), Unit>`, but got `Int`.
1720
// -| src/test_files/check/assign_toplevel_fun_name.gdn:2:9
1821
// 1| public fun foo() {
1922
// 2| bar = 1
20-
// 3| } ^
21-
//
22-
// Warning: `bar` is not read after this assignment.
23-
// -| src/test_files/check/assign_toplevel_fun_name.gdn:2:3
24-
// 1| public fun foo() {
25-
// 2| bar = 1
26-
// 3| } ^^^^^^^
23+
// | ^
24+
// 3| let _ = bar
25+
// 4| }
2726

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
public fun foo() {
22
let x = todo()
33
x += 1
4+
let _a = x
45

56
let y = no_such_func()
67
y += 1
8+
let _b = y
79
}
810

911
// args: check
1012
// expected exit status: 1
1113
// expected stdout:
1214
// Warning: Unfinished code.
13-
// -| src/test_files/check/assign_update_error_type.gdn:2:11
14-
// 1| public fun foo() {
15-
// 2| let x = todo()
16-
// 3| x += 1 ^^^^^^
15+
// --| src/test_files/check/assign_update_error_type.gdn:2:11
16+
// 1| public fun foo() {
17+
// 2| let x = todo()
18+
// 3| x += 1 ^^^^^^
19+
// 4| let _a = x
1720
//
1821
// Error: Unbound symbol: `no_such_func`
19-
// -| src/test_files/check/assign_update_error_type.gdn:5:11
20-
// 3| x += 1
21-
// 4|
22-
// 5| let y = no_such_func()
23-
// 6| y += 1 ^^^^^^^^^^^^
24-
// 7| }
25-
//
26-
// Warning: `x` is not read after this assignment.
27-
// -| src/test_files/check/assign_update_error_type.gdn:3:3
28-
// 1| public fun foo() {
29-
// 2| let x = todo()
30-
// 3| x += 1
31-
// 4| ^^^^^^
32-
// 5| let y = no_such_func()
33-
//
34-
// Warning: `y` is not read after this assignment.
35-
// -| src/test_files/check/assign_update_error_type.gdn:6:3
36-
// 5| let y = no_such_func()
37-
// 6| y += 1
38-
// 7| } ^^^^^^
22+
// --| src/test_files/check/assign_update_error_type.gdn:6:11
23+
// 4| let _a = x
24+
// 5|
25+
// 6| let y = no_such_func()
26+
// 7| y += 1 ^^^^^^^^^^^^
27+
// 8| let _b = y
3928

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
public fun foo() {
22
let x = 1
33
x = ""
4+
let _ = x
45
}
56

67
// args: check
@@ -11,12 +12,7 @@ public fun foo() {
1112
// 1| public fun foo() {
1213
// 2| let x = 1
1314
// 3| x = ""
14-
// 4| } ^^
15-
//
16-
// Warning: `x` is not read after this assignment.
17-
// -| src/test_files/check/assign_wrong_type.gdn:3:5
18-
// 1| public fun foo() {
19-
// 2| let x = 1
20-
// 3| x = ""
21-
// 4| } ^^^^^^
15+
// | ^^
16+
// 4| let _ = x
17+
// 5| }
2218

0 commit comments

Comments
 (0)