mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
Detect unused variables
This commit is contained in:
parent
f164aad631
commit
9270f52e6b
33 changed files with 340 additions and 63 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//@check-pass
|
||||
|
||||
function dropping(a: I32) =
|
||||
function dropping(_a: I32) =
|
||||
___asm(
|
||||
__locals(),
|
||||
"local.get 0",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function a(a: I32) =
|
||||
function a(_a: I32) =
|
||||
___asm(
|
||||
__locals(),
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dropping(a: I32) =
|
||||
function dropping(_a: I32) =
|
||||
___asm(
|
||||
__locals(),
|
||||
"meow meow",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dropping(a: I32) =
|
||||
function dropping(_a: I32) =
|
||||
___asm(
|
||||
"local.get 0",
|
||||
"drop",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
function dropping(a: I32) = (
|
||||
function dropping(_a: I32) = (
|
||||
1;
|
||||
___asm(__locals(), "drop");
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
function a(a: I32) =
|
||||
function a(_a: I32) =
|
||||
___asm(
|
||||
__locals(),
|
||||
"local.get 0 0",
|
||||
"drop",
|
||||
);
|
||||
|
||||
function b(a: I32) =
|
||||
function b(_a: I32) =
|
||||
___asm(
|
||||
__locals(),
|
||||
"local.get",
|
||||
|
|
|
|||
|
|
@ -10,3 +10,11 @@ error: cannot assign String to Int
|
|||
--> $DIR/basic_recovery.nil:3
|
||||
3 | let b: Int = "";
|
||||
^
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/basic_recovery.nil:2
|
||||
2 | let a: Int = "";
|
||||
^
|
||||
warning: unused variable: `b`
|
||||
--> $DIR/basic_recovery.nil:3
|
||||
3 | let b: Int = "";
|
||||
^
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ function main() = (
|
|||
singleArg("hi!");
|
||||
manyArgs(1,2,3,4,5,6);
|
||||
|
||||
let a: () = returnNothing();
|
||||
let b: () = returnExplicitUnit();
|
||||
let c: String = returnString();
|
||||
let _a: () = returnNothing();
|
||||
let _b: () = returnExplicitUnit();
|
||||
let _c: String = returnString();
|
||||
);
|
||||
|
||||
function noArgs() =;
|
||||
function singleArg(a: String) =;
|
||||
function manyArgs(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) =;
|
||||
function singleArg(_a: String) =;
|
||||
function manyArgs(_a: Int, _b: Int, _c: Int, _d: Int, _e: Int, _f: Int) =;
|
||||
|
||||
function returnNothing() =;
|
||||
function returnExplicitUnit(): () =;
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ function main() = (
|
|||
x();
|
||||
);
|
||||
|
||||
function x(a: Int) = ;
|
||||
function x(_a: Int) = ;
|
||||
22
ui-tests/lint/unused_vars.nil
Normal file
22
ui-tests/lint/unused_vars.nil
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//@check-pass
|
||||
|
||||
function main() = (
|
||||
let x = 0;
|
||||
let _ok = 0;
|
||||
let used = 0;
|
||||
|
||||
used;
|
||||
);
|
||||
|
||||
function x() = (
|
||||
let x = 0;
|
||||
(
|
||||
let x = 0;
|
||||
call(x);
|
||||
);
|
||||
let y = x;
|
||||
);
|
||||
|
||||
function call(_a: Int) = ;
|
||||
|
||||
function param(p: Int) = ;
|
||||
12
ui-tests/lint/unused_vars.stderr
Normal file
12
ui-tests/lint/unused_vars.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
warning: unused variable: `x`
|
||||
--> $DIR/unused_vars.nil:4
|
||||
4 | let x = 0;
|
||||
^
|
||||
warning: unused variable: `y`
|
||||
--> $DIR/unused_vars.nil:17
|
||||
17 | let y = x;
|
||||
^
|
||||
warning: unused function parameter: `p`
|
||||
--> $DIR/unused_vars.nil:22
|
||||
22 | function param(p: Int) = ;
|
||||
^
|
||||
|
|
@ -2,3 +2,7 @@ error: type I32 does not take any generic arguments but 1 were passed
|
|||
--> $DIR/generics_on_primitive.nil:2
|
||||
2 | let a: I32[I32] = 0;
|
||||
^^^
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/generics_on_primitive.nil:2
|
||||
2 | let a: I32[I32] = 0;
|
||||
^
|
||||
|
|
|
|||
12
ui-tests/type/generics/generics_structs_in_args.stderr
Normal file
12
ui-tests/type/generics/generics_structs_in_args.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
warning: unused function parameter: `a`
|
||||
--> $DIR/generics_structs_in_args.nil:11
|
||||
11 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
warning: unused function parameter: `b`
|
||||
--> $DIR/generics_structs_in_args.nil:11
|
||||
11 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
warning: unused function parameter: `c`
|
||||
--> $DIR/generics_structs_in_args.nil:11
|
||||
11 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
12
ui-tests/type/generics/structs.stderr
Normal file
12
ui-tests/type/generics/structs.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
warning: unused function parameter: `a`
|
||||
--> $DIR/structs.nil:9
|
||||
9 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
warning: unused function parameter: `b`
|
||||
--> $DIR/structs.nil:9
|
||||
9 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
warning: unused function parameter: `c`
|
||||
--> $DIR/structs.nil:9
|
||||
9 | function test(a: A[I32], b: B[I32, Int, I32], c: C) = ;
|
||||
^
|
||||
|
|
@ -22,3 +22,51 @@ error: type () does not take any generic arguments but 1 were passed
|
|||
--> $DIR/wrong_amount.nil:22
|
||||
22 | c3: C[I32],
|
||||
^
|
||||
warning: unused function parameter: `a1`
|
||||
--> $DIR/wrong_amount.nil:9
|
||||
9 | a1: A,
|
||||
^^
|
||||
warning: unused function parameter: `a2`
|
||||
--> $DIR/wrong_amount.nil:10
|
||||
10 | a2: A[],
|
||||
^^
|
||||
warning: unused function parameter: `a3`
|
||||
--> $DIR/wrong_amount.nil:11
|
||||
11 | a3: A[I32],
|
||||
^^
|
||||
warning: unused function parameter: `a4`
|
||||
--> $DIR/wrong_amount.nil:12
|
||||
12 | a4: A[I32, I32],
|
||||
^^
|
||||
warning: unused function parameter: `b1`
|
||||
--> $DIR/wrong_amount.nil:14
|
||||
14 | b1: B,
|
||||
^^
|
||||
warning: unused function parameter: `b2`
|
||||
--> $DIR/wrong_amount.nil:15
|
||||
15 | b2: B[],
|
||||
^^
|
||||
warning: unused function parameter: `b3`
|
||||
--> $DIR/wrong_amount.nil:16
|
||||
16 | b3: B[Int, Int],
|
||||
^^
|
||||
warning: unused function parameter: `b4`
|
||||
--> $DIR/wrong_amount.nil:17
|
||||
17 | b4: B[Int, I32, Int],
|
||||
^^
|
||||
warning: unused function parameter: `b5`
|
||||
--> $DIR/wrong_amount.nil:18
|
||||
18 | b5: B[Int, Int, Int, Int],
|
||||
^^
|
||||
warning: unused function parameter: `c1`
|
||||
--> $DIR/wrong_amount.nil:20
|
||||
20 | c1: C,
|
||||
^^
|
||||
warning: unused function parameter: `c2`
|
||||
--> $DIR/wrong_amount.nil:21
|
||||
21 | c2: C[],
|
||||
^^
|
||||
warning: unused function parameter: `c3`
|
||||
--> $DIR/wrong_amount.nil:22
|
||||
22 | c3: C[I32],
|
||||
^^
|
||||
|
|
|
|||
4
ui-tests/type/type_alias.stderr
Normal file
4
ui-tests/type/type_alias.stderr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
warning: unused variable: `a`
|
||||
--> $DIR/type_alias.nil:6
|
||||
6 | let a: A = (0, 0);
|
||||
^
|
||||
24
ui-tests/type/type_assignments.stderr
Normal file
24
ui-tests/type/type_assignments.stderr
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
warning: unused variable: `a1`
|
||||
--> $DIR/type_assignments.nil:15
|
||||
15 | let a1: Int = a;
|
||||
^^
|
||||
warning: unused variable: `b1`
|
||||
--> $DIR/type_assignments.nil:16
|
||||
16 | let b1: I32 = b;
|
||||
^^
|
||||
warning: unused variable: `c1`
|
||||
--> $DIR/type_assignments.nil:17
|
||||
17 | let c1: String = c;
|
||||
^^
|
||||
warning: unused variable: `d1`
|
||||
--> $DIR/type_assignments.nil:18
|
||||
18 | let d1: Bool = d;
|
||||
^^
|
||||
warning: unused variable: `e1`
|
||||
--> $DIR/type_assignments.nil:19
|
||||
19 | let e1: CustomType = e;
|
||||
^^
|
||||
warning: unused variable: `f1`
|
||||
--> $DIR/type_assignments.nil:20
|
||||
20 | let f1: (Int, I32) = f;
|
||||
^^
|
||||
Loading…
Add table
Add a link
Reference in a new issue