parser: `expression evaluated but not used` error
parent
f2d9fa3815
commit
2daf915371
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||
vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | Aaa{} + 10
|
||||
3 | println(Aaa{} + 10)
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
Aaa{} + 10
|
||||
println(Aaa{} + 10)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int`
|
||||
vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | [1,2,3] + 10
|
||||
2 | println([1,2,3] + 10)
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
[1,2,3] + 10
|
||||
println([1,2,3] + 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/add_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int`
|
||||
vlib/v/checker/tests/add_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | a + 10
|
||||
3 | println(a + 10)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
a + 10
|
||||
println(a + 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||
vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | 10 + Aaa{}
|
||||
3 | println(10 + Aaa{})
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
10 + Aaa{}
|
||||
println(10 + Aaa{})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int`
|
||||
vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int`
|
||||
1 | fn main() {
|
||||
2 | 10 + [1,2,3]
|
||||
2 | println(10 + [1,2,3])
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
10 + [1,2,3]
|
||||
println(10 + [1,2,3])
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/add_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int`
|
||||
vlib/v/checker/tests/add_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | 10 + a
|
||||
3 | println(10 + a)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
10 + a
|
||||
println(10 + a)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/bit_op_wrong_left_type_err.v:2:2: error: left type of `&` cannot be non-integer type any_float
|
||||
vlib/v/checker/tests/bit_op_wrong_left_type_err.v:2:10: error: left type of `&` cannot be non-integer type any_float
|
||||
1 | fn main() {
|
||||
2 | 0.5 & 1
|
||||
2 | println(0.5 & 1)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
0.5 & 1
|
||||
println(0.5 & 1)
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/bit_op_wrong_right_type_err.v:2:6: error: right type of `|` cannot be non-integer type any_float
|
||||
vlib/v/checker/tests/bit_op_wrong_right_type_err.v:2:14: error: right type of `|` cannot be non-integer type any_float
|
||||
1 | fn main() {
|
||||
2 | 1 | 0.5
|
||||
2 | println(1 | 0.5)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
1 | 0.5
|
||||
println(1 | 0.5)
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||
vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | Aaa{} / 10
|
||||
3 | println(Aaa{} / 10)
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
Aaa{} / 10
|
||||
println(Aaa{} / 10)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int`
|
||||
vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | [1,2,3] / 10
|
||||
2 | println([1,2,3] / 10)
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
[1,2,3] / 10
|
||||
println([1,2,3] / 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/div_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int`
|
||||
vlib/v/checker/tests/div_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | a / 10
|
||||
3 | println(a / 10)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
a / 10
|
||||
println(a / 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||
vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | 10 / Aaa{}
|
||||
3 | println(10 / Aaa{})
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
10 / Aaa{}
|
||||
println(10 / Aaa{})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int`
|
||||
vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int`
|
||||
1 | fn main() {
|
||||
2 | 10 / [1,2,3]
|
||||
2 | println(10 / [1,2,3])
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
10 / [1,2,3]
|
||||
println(10 / [1,2,3])
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/div_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int`
|
||||
vlib/v/checker/tests/div_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | 10 / a
|
||||
3 | println(10 / a)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
10 / a
|
||||
println(10 / a)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||
vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | Aaa{} - 10
|
||||
3 | println(Aaa{} - 10)
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
Aaa{} - 10
|
||||
println(Aaa{} - 10)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int`
|
||||
vlib/v/checker/tests/minus_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | [1,2,3] - 10
|
||||
2 | println([1,2,3] - 10)
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
[1,2,3] - 10
|
||||
println([1,2,3] - 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int`
|
||||
vlib/v/checker/tests/minus_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | a - 10
|
||||
3 | println(a - 10)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
a - 10
|
||||
println(a - 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||
vlib/v/checker/tests/minus_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | 10 - Aaa{}
|
||||
3 | println(10 - Aaa{})
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
10 - Aaa{}
|
||||
println(10 - Aaa{})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int`
|
||||
vlib/v/checker/tests/minus_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int`
|
||||
1 | fn main() {
|
||||
2 | 10 - [1,2,3]
|
||||
2 | println(10 - [1,2,3])
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
10 - [1,2,3]
|
||||
println(10 - [1,2,3])
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/minus_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int`
|
||||
vlib/v/checker/tests/minus_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | 10 - a
|
||||
3 | println(10 - a)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
10 - a
|
||||
println(10 - a)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_left_type_err_a.v:2:2: error: float modulo not allowed, use math.fmod() instead
|
||||
vlib/v/checker/tests/mod_op_wrong_left_type_err_a.v:2:10: error: float modulo not allowed, use math.fmod() instead
|
||||
1 | fn main() {
|
||||
2 | 0.5 % 1
|
||||
2 | println(0.5 % 1)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
0.5 % 1
|
||||
println(0.5 % 1)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_left_type_err_b.v:2:2: error: mismatched types `array_int` and `any_int`
|
||||
vlib/v/checker/tests/mod_op_wrong_left_type_err_b.v:2:10: error: mismatched types `array_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | [1,2,3] % 1
|
||||
2 | println([1,2,3] % 1)
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
[1,2,3] % 1
|
||||
println([1,2,3] % 1)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:2: error: mismatched types `Aaa` and `any_int`
|
||||
vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:10: error: mismatched types `Aaa` and `any_int`
|
||||
2 | fn main() {
|
||||
3 | a := Aaa{}
|
||||
4 | a % 1
|
||||
4 | println(a % 1)
|
||||
| ^
|
||||
5 | }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
a := Aaa{}
|
||||
a % 1
|
||||
println(a % 1)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_left_type_err_d.v:3:2: error: mismatched types `map_string_int` and `any_int`
|
||||
vlib/v/checker/tests/mod_op_wrong_left_type_err_d.v:3:10: error: mismatched types `map_string_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | a % 1
|
||||
3 | println(a % 1)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
a % 1
|
||||
println(a % 1)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_right_type_err_a.v:2:6: error: float modulo not allowed, use math.fmod() instead
|
||||
vlib/v/checker/tests/mod_op_wrong_right_type_err_a.v:2:14: error: float modulo not allowed, use math.fmod() instead
|
||||
1 | fn main() {
|
||||
2 | 1 % 0.5
|
||||
2 | println(1 % 0.5)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
1 % 0.5
|
||||
println(1 % 0.5)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_right_type_err_b.v:2:6: error: mismatched types `any_int` and `array_int`
|
||||
vlib/v/checker/tests/mod_op_wrong_right_type_err_b.v:2:14: error: mismatched types `any_int` and `array_int`
|
||||
1 | fn main() {
|
||||
2 | 1 % [1,2,3]
|
||||
2 | println(1 % [1,2,3])
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
1 % [1,2,3]
|
||||
println(1 % [1,2,3])
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:6: error: mismatched types `any_int` and `Aaa`
|
||||
vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:14: error: mismatched types `any_int` and `Aaa`
|
||||
2 | fn main() {
|
||||
3 | a := Aaa{}
|
||||
4 | 1 % a
|
||||
4 | println(1 % a)
|
||||
| ^
|
||||
5 | }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
a := Aaa{}
|
||||
1 % a
|
||||
println(1 % a)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mod_op_wrong_right_type_err_d.v:3:6: error: mismatched types `any_int` and `map_string_int`
|
||||
vlib/v/checker/tests/mod_op_wrong_right_type_err_d.v:3:14: error: mismatched types `any_int` and `map_string_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | 1 % a
|
||||
3 | println(1 % a)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
1 % a
|
||||
println(1 % a)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||
vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | Aaa{} * 10
|
||||
3 | println(Aaa{} * 10)
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
Aaa{} * 10
|
||||
println(Aaa{} * 10)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int`
|
||||
vlib/v/checker/tests/mul_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | [1,2,3] * 10
|
||||
2 | println([1,2,3] * 10)
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
[1,2,3] * 10
|
||||
println([1,2,3] * 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int`
|
||||
vlib/v/checker/tests/mul_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | a * 10
|
||||
3 | println(a * 10)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
a * 10
|
||||
println(a * 10)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||
vlib/v/checker/tests/mul_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa`
|
||||
1 | struct Aaa{}
|
||||
2 | fn main() {
|
||||
3 | 10 * Aaa{}
|
||||
3 | println(10 * Aaa{})
|
||||
| ~~~~~
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
struct Aaa{}
|
||||
fn main() {
|
||||
10 * Aaa{}
|
||||
println(10 * Aaa{})
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int`
|
||||
vlib/v/checker/tests/mul_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int`
|
||||
1 | fn main() {
|
||||
2 | 10 * [1,2,3]
|
||||
2 | println(10 * [1,2,3])
|
||||
| ~~~~~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
10 * [1,2,3]
|
||||
println(10 * [1,2,3])
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
vlib/v/checker/tests/mul_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int`
|
||||
vlib/v/checker/tests/mul_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int`
|
||||
1 | fn main() {
|
||||
2 | a := map[string]int
|
||||
3 | 10 * a
|
||||
3 | println(10 * a)
|
||||
| ^
|
||||
4 | }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
a := map[string]int
|
||||
10 * a
|
||||
println(10 * a)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/rshift_op_wrong_left_type_err.v:2:2: error: cannot shift type any_int into non-integer type any_float
|
||||
vlib/v/checker/tests/rshift_op_wrong_left_type_err.v:2:10: error: cannot shift type any_int into non-integer type any_float
|
||||
1 | fn main() {
|
||||
2 | 0.5 >> 1
|
||||
2 | println(0.5 >> 1)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
0.5 >> 1
|
||||
println(0.5 >> 1)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/rshift_op_wrong_right_type_err.v:2:7: error: cannot shift non-integer type any_float into type any_int
|
||||
vlib/v/checker/tests/rshift_op_wrong_right_type_err.v:2:15: error: cannot shift non-integer type any_float into type any_int
|
||||
1 | fn main() {
|
||||
2 | 1 >> 0.5
|
||||
2 | println(1 >> 0.5)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
1 >> 0.5
|
||||
println(1 >> 0.5)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/shift_op_wrong_left_type_err.v:2:2: error: cannot shift type any_int into non-integer type any_float
|
||||
vlib/v/checker/tests/shift_op_wrong_left_type_err.v:2:10: error: cannot shift type any_int into non-integer type any_float
|
||||
1 | fn main() {
|
||||
2 | 0.5 << 1
|
||||
2 | println(0.5 << 1)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
0.5 << 1
|
||||
println(0.5 << 1)
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
vlib/v/checker/tests/shift_op_wrong_right_type_err.v:2:7: error: cannot shift non-integer type any_float into type any_int
|
||||
vlib/v/checker/tests/shift_op_wrong_right_type_err.v:2:15: error: cannot shift non-integer type any_float into type any_int
|
||||
1 | fn main() {
|
||||
2 | 1 << 0.5
|
||||
2 | println(1 << 0.5)
|
||||
| ~~~
|
||||
3 | }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
1 << 0.5
|
||||
println(1 << 0.5)
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
fn char_backtick() {
|
||||
`\``
|
||||
println(`\``)
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ fn (f Foo) fn_with_optional() ?int {
|
|||
return 40
|
||||
}
|
||||
|
||||
fn mut_array(a mut []int) {
|
||||
fn mut_array(mut a []int) {
|
||||
println(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
fn main() {
|
||||
'Hello world !'
|
||||
'This is correct !'
|
||||
"It's okay"
|
||||
'This is "too"'
|
||||
println('Hello world !')
|
||||
println('This is correct !')
|
||||
println("It's okay")
|
||||
println('This is "too"')
|
||||
// TODO
|
||||
// 'I\'m not correctly formatted' => "I'm not correctly formatted"
|
||||
// "\"Everything on the internet is true\" - Albert Einstein, 1965" => '"Everything on the internet is true" - Albert Einstein, 1965'
|
||||
'I\'m out of idea "_"'
|
||||
println('I\'m out of idea "_"')
|
||||
// "Definitely out \":'(\"" => 'Definitely out ":\'("'
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
fn main() {
|
||||
"Hello world !"
|
||||
'This is correct !'
|
||||
"It's okay"
|
||||
'This is "too"'
|
||||
println("Hello world !")
|
||||
println('This is correct !')
|
||||
println("It's okay")
|
||||
println('This is "too"')
|
||||
// TODO
|
||||
// 'I\'m not correctly formatted' => "I'm not correctly formatted"
|
||||
// "\"Everything on the internet is true\" - Albert Einstein, 1965" => '"Everything on the internet is true" - Albert Einstein, 1965'
|
||||
'I\'m out of idea "_"'
|
||||
println('I\'m out of idea "_"')
|
||||
// "Definitely out \":'(\"" => 'Definitely out ":\'("'
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt {
|
|||
}
|
||||
p.init_parse_fns()
|
||||
p.read_first_token()
|
||||
return p.stmt()
|
||||
return p.stmt(false)
|
||||
}
|
||||
|
||||
pub fn parse_text(text string, b_table &table.Table, pref &pref.Preferences, scope, global_scope &ast.Scope) ast.File {
|
||||
|
@ -317,7 +317,7 @@ pub fn (mut p Parser) parse_block_no_scope(is_top_level bool) []ast.Stmt {
|
|||
mut stmts := []ast.Stmt{}
|
||||
if p.tok.kind != .rcbr {
|
||||
for {
|
||||
stmts << p.stmt()
|
||||
stmts << p.stmt(is_top_level)
|
||||
// p.warn('after stmt(): tok=$p.tok.str()')
|
||||
if p.tok.kind in [.eof, .rcbr] {
|
||||
break
|
||||
|
@ -464,7 +464,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
|||
if p.pref.is_script && !p.pref.is_test {
|
||||
mut stmts := []ast.Stmt{}
|
||||
for p.tok.kind != .eof {
|
||||
stmts << p.stmt()
|
||||
stmts << p.stmt(false)
|
||||
}
|
||||
return ast.FnDecl{
|
||||
name: 'main'
|
||||
|
@ -500,7 +500,7 @@ pub fn (mut p Parser) comment() ast.Comment {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut p Parser) stmt() ast.Stmt {
|
||||
pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
|
||||
p.is_stmt_ident = p.tok.kind == .name
|
||||
match p.tok.kind {
|
||||
.lcbr {
|
||||
|
@ -530,7 +530,7 @@ pub fn (mut p Parser) stmt() ast.Stmt {
|
|||
return p.assign_stmt()
|
||||
} else if p.peek_tok.kind == .comma {
|
||||
// `a, b ...`
|
||||
return p.parse_multi_expr()
|
||||
return p.parse_multi_expr(is_top_level)
|
||||
} else if p.peek_tok.kind == .colon {
|
||||
// `label:`
|
||||
name := p.check_name()
|
||||
|
@ -544,7 +544,7 @@ pub fn (mut p Parser) stmt() ast.Stmt {
|
|||
[.rcbr, .eof] {
|
||||
p.error_with_pos('`$p.tok.lit` evaluated but not used', p.tok.position())
|
||||
}
|
||||
return p.parse_multi_expr()
|
||||
return p.parse_multi_expr(is_top_level)
|
||||
}
|
||||
.comment {
|
||||
return p.comment()
|
||||
|
@ -613,7 +613,7 @@ pub fn (mut p Parser) stmt() ast.Stmt {
|
|||
}
|
||||
// literals, 'if', etc. in here
|
||||
else {
|
||||
return p.parse_multi_expr()
|
||||
return p.parse_multi_expr(is_top_level)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -733,11 +733,12 @@ pub fn (mut p Parser) warn_with_pos(s string, pos token.Position) {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut p Parser) parse_multi_expr() ast.Stmt {
|
||||
fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
|
||||
// in here might be 1) multi-expr 2) multi-assign
|
||||
// 1, a, c ... } // multi-expression
|
||||
// a, mut b ... :=/= // multi-assign
|
||||
// collect things upto hard boundaries
|
||||
tok_kind := p.tok.kind
|
||||
mut collected := []ast.Expr{}
|
||||
for {
|
||||
collected << p.expr(0)
|
||||
|
@ -773,6 +774,11 @@ fn (mut p Parser) parse_multi_expr() ast.Stmt {
|
|||
})
|
||||
pos: epos
|
||||
}
|
||||
} else if is_top_level && collected.len > 0 && collected[0] !is ast.AssignExpr &&
|
||||
collected[0] !is ast.CallExpr && collected[0] !is ast.PostfixExpr &&
|
||||
!(collected[0] is ast.InfixExpr && (collected[0] as ast.InfixExpr).op == .left_shift) &&
|
||||
collected[0] !is ast.ComptimeCall && tok_kind !in [.key_if, .key_match] {
|
||||
p.error_with_pos('expression evaluated but not used', collected[0].position())
|
||||
} else {
|
||||
if collected.len == 1 {
|
||||
return ast.ExprStmt{
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
vlib/v/parser/tests/expr_evaluated_but_not_used_a.v:2:2: error: expression evaluated but not used
|
||||
1 | fn main() {
|
||||
2 | 'hello'
|
||||
| ~~~~~~~
|
||||
3 | }
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
'hello'
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
vlib/v/parser/tests/expr_evaluated_but_not_used_b.v:2:2: error: expression evaluated but not used
|
||||
1 | fn main() {
|
||||
2 | 22
|
||||
| ~~
|
||||
3 | }
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
22
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/parser/tests/expr_evaluated_but_not_used_c.v:3:5: error: expression evaluated but not used
|
||||
1 | fn main() {
|
||||
2 | a := 10
|
||||
3 | `b`
|
||||
| ~~~
|
||||
4 | println(a)
|
||||
5 | }
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
a := 10
|
||||
`b`
|
||||
println(a)
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/parser/tests/expr_evaluated_but_not_used_d.v:4:5: error: expression evaluated but not used
|
||||
2 | a := 1
|
||||
3 | b := 2
|
||||
4 | a+b
|
||||
| ~~~
|
||||
5 | println(a*b)
|
||||
6 | }
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
a := 1
|
||||
b := 2
|
||||
a+b
|
||||
println(a*b)
|
||||
}
|
Loading…
Reference in New Issue