all: fix struct names error
parent
670820cc59
commit
84edbd83da
|
@ -89,7 +89,7 @@ struct Chunk {
|
||||||
val string
|
val string
|
||||||
}
|
}
|
||||||
|
|
||||||
struct K {
|
struct Kkk {
|
||||||
q []Chunk
|
q []Chunk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ struct User {
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
struct A {
|
struct Aaa {
|
||||||
mut:
|
mut:
|
||||||
m map[string]int
|
m map[string]int
|
||||||
users map[string]User
|
users map[string]User
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut a A) set(key string, val int) {
|
fn (mut a Aaa) set(key string, val int) {
|
||||||
a.m[key] = val
|
a.m[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ fn test_map() {
|
||||||
users['1'] = User{'Peter'}
|
users['1'] = User{'Peter'}
|
||||||
peter := users['1']
|
peter := users['1']
|
||||||
assert peter.name == 'Peter'
|
assert peter.name == 'Peter'
|
||||||
mut a := A{
|
mut a := Aaa{
|
||||||
m: map[string]int
|
m: map[string]int
|
||||||
users: map[string]User
|
users: map[string]User
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `any_int`
|
vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | A{} + 10
|
3 | Aaa{} + 10
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
A{} + 10
|
Aaa{} + 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 `A`
|
vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | 10 + A{}
|
3 | 10 + Aaa{}
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
10 + A{}
|
10 + Aaa{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `any_int`
|
vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | A{} / 10
|
3 | Aaa{} / 10
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
A{} / 10
|
Aaa{} / 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 `A`
|
vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | 10 / A{}
|
3 | 10 / Aaa{}
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
10 / A{}
|
10 / Aaa{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/immutable_array_field_assign.v:9:4: error: field `i` of struct `A` is immutable
|
vlib/v/checker/tests/immutable_array_field_assign.v:9:4: error: field `i` of struct `Aaa` is immutable
|
||||||
7 | i: [0]
|
7 | i: [0]
|
||||||
8 | }
|
8 | }
|
||||||
9 | a.i[0] = 3
|
9 | a.i[0] = 3
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
i []int
|
i []int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut a := A{
|
mut a := Aaa{
|
||||||
i: [0]
|
i: [0]
|
||||||
}
|
}
|
||||||
a.i[0] = 3
|
a.i[0] = 3
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
vlib/v/checker/tests/immutable_array_field_shift.v:14:4: error: field `a` of struct `B` is immutable
|
vlib/v/checker/tests/immutable_array_field_shift.v:14:4: error: field `a` of struct `Bbb` is immutable
|
||||||
12 | a: A{}
|
12 | a: Aaa{}
|
||||||
13 | }
|
13 | }
|
||||||
14 | b.a.i << 3
|
14 | b.a.i << 3
|
||||||
| ^
|
| ^
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
mut:
|
mut:
|
||||||
i []int
|
i []int
|
||||||
}
|
}
|
||||||
|
|
||||||
struct B {
|
struct Bbb {
|
||||||
a A
|
a Aaa
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut b := B{
|
mut b := Bbb{
|
||||||
a: A{}
|
a: Aaa{}
|
||||||
}
|
}
|
||||||
b.a.i << 3
|
b.a.i << 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/immutable_array_struct_assign.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
vlib/v/checker/tests/immutable_array_struct_assign.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
||||||
6 | fn main() {
|
6 | fn main() {
|
||||||
7 | a := A{}
|
7 | a := Aaa{}
|
||||||
8 | a.i[0] += 3
|
8 | a.i[0] += 3
|
||||||
| ^
|
| ^
|
||||||
9 | }
|
9 | }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
pub mut:
|
pub mut:
|
||||||
i []int
|
i []int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
a.i[0] += 3
|
a.i[0] += 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/immutable_array_struct_shift.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
vlib/v/checker/tests/immutable_array_struct_shift.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
||||||
6 | fn main() {
|
6 | fn main() {
|
||||||
7 | a := []A{}
|
7 | a := []Aaa{}
|
||||||
8 | a[0].i << 3
|
8 | a[0].i << 3
|
||||||
| ^
|
| ^
|
||||||
9 | }
|
9 | }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
pub mut:
|
pub mut:
|
||||||
i []int
|
i []int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := []A{}
|
a := []Aaa{}
|
||||||
a[0].i << 3
|
a[0].i << 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/immutable_field.v:8:4: error: field `i1` of struct `A` is immutable
|
vlib/v/checker/tests/immutable_field.v:8:4: error: field `i1` of struct `Aaa` is immutable
|
||||||
6 | fn main() {
|
6 | fn main() {
|
||||||
7 | a := A{1}
|
7 | a := Aaa{1}
|
||||||
8 | a.i1 = 2
|
8 | a.i1 = 2
|
||||||
| ~~
|
| ~~
|
||||||
9 | }
|
9 | }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
pub:
|
pub:
|
||||||
i1 int
|
i1 int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{1}
|
a := Aaa{1}
|
||||||
a.i1 = 2
|
a.i1 = 2
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
vlib/v/checker/tests/immutable_field_postfix.v:7:4: error: field `i` of struct `A` is immutable
|
vlib/v/checker/tests/immutable_field_postfix.v:7:4: error: field `i` of struct `Aaa` is immutable
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | mut a := A{}
|
6 | mut a := Aaa{}
|
||||||
7 | a.i++
|
7 | a.i++
|
||||||
| ^
|
| ^
|
||||||
8 | a.i--
|
8 | a.i--
|
||||||
9 | }
|
9 | }
|
||||||
vlib/v/checker/tests/immutable_field_postfix.v:8:4: error: field `i` of struct `A` is immutable
|
vlib/v/checker/tests/immutable_field_postfix.v:8:4: error: field `i` of struct `Aaa` is immutable
|
||||||
6 | mut a := A{}
|
6 | mut a := Aaa{}
|
||||||
7 | a.i++
|
7 | a.i++
|
||||||
8 | a.i--
|
8 | a.i--
|
||||||
| ^
|
| ^
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
i int
|
i int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut a := A{}
|
mut a := Aaa{}
|
||||||
a.i++
|
a.i++
|
||||||
a.i--
|
a.i--
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
vlib/v/checker/tests/immutable_struct_postfix.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
vlib/v/checker/tests/immutable_struct_postfix.v:8:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
||||||
6 | fn main() {
|
6 | fn main() {
|
||||||
7 | a := A{}
|
7 | a := Aaa{}
|
||||||
8 | a.i++
|
8 | a.i++
|
||||||
| ^
|
| ^
|
||||||
9 | a.i--
|
9 | a.i--
|
||||||
10 | }
|
10 | }
|
||||||
vlib/v/checker/tests/immutable_struct_postfix.v:9:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
vlib/v/checker/tests/immutable_struct_postfix.v:9:2: error: `a` is immutable, declare it with `mut` to make it mutable
|
||||||
7 | a := A{}
|
7 | a := Aaa{}
|
||||||
8 | a.i++
|
8 | a.i++
|
||||||
9 | a.i--
|
9 | a.i--
|
||||||
| ^
|
| ^
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
mut:
|
mut:
|
||||||
i int
|
i int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
a.i++
|
a.i++
|
||||||
a.i--
|
a.i--
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `any_int`
|
vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | A{} - 10
|
3 | Aaa{} - 10
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
A{} - 10
|
Aaa{} - 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 `A`
|
vlib/v/checker/tests/minus_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | 10 - A{}
|
3 | 10 - Aaa{}
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
10 - A{}
|
10 - Aaa{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:2: error: mismatched types `A` and `any_int`
|
vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:2: error: mismatched types `Aaa` and `any_int`
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | a := A{}
|
3 | a := Aaa{}
|
||||||
4 | a % 1
|
4 | a % 1
|
||||||
| ^
|
| ^
|
||||||
5 | }
|
5 | }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
a % 1
|
a % 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:6: error: mismatched types `any_int` and `A`
|
vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:6: error: mismatched types `any_int` and `Aaa`
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | a := A{}
|
3 | a := Aaa{}
|
||||||
4 | 1 % a
|
4 | 1 % a
|
||||||
| ^
|
| ^
|
||||||
5 | }
|
5 | }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
1 % a
|
1 % a
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `any_int`
|
vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | A{} * 10
|
3 | Aaa{} * 10
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
A{} * 10
|
Aaa{} * 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 `A`
|
vlib/v/checker/tests/mul_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa`
|
||||||
1 | struct A{}
|
1 | struct Aaa{}
|
||||||
2 | fn main() {
|
2 | fn main() {
|
||||||
3 | 10 * A{}
|
3 | 10 * Aaa{}
|
||||||
| ~~~
|
| ~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A{}
|
struct Aaa{}
|
||||||
fn main() {
|
fn main() {
|
||||||
10 * A{}
|
10 * Aaa{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
vlib/v/checker/tests/struct_field_name_duplicate_err.v:3:2: error: field name `a` duplicate
|
vlib/v/checker/tests/struct_field_name_duplicate_err.v:3:2: error: field name `a` duplicate
|
||||||
1 | struct A {
|
1 | struct Aaa {
|
||||||
2 | a int
|
2 | a int
|
||||||
3 | a string
|
3 | a string
|
||||||
| ~~~~~~~~
|
| ~~~~~~~~
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
a int
|
a int
|
||||||
a string
|
a string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/checker/tests/unknown_field.v:7:12: error: unknown field `Test.sdd`
|
vlib/v/checker/tests/unknown_field.v:7:12: error: type `Test` has no field or method `sdd`
|
||||||
5 | fn main() {
|
5 | fn main() {
|
||||||
6 | t := Test{}
|
6 | t := Test{}
|
||||||
7 | println(t.sdd)
|
7 | println(t.sdd)
|
||||||
|
|
|
@ -7,21 +7,21 @@ pub const (
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub struct A {
|
pub struct Aaa {
|
||||||
pub mut:
|
pub mut:
|
||||||
foo string
|
foo string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut a A) update(s string) {
|
pub fn (mut a Aaa) update(s string) {
|
||||||
a.foo = s
|
a.foo = s
|
||||||
}
|
}
|
||||||
|
|
||||||
struct B {}
|
struct Bbb {}
|
||||||
|
|
||||||
pub enum C {}
|
pub enum Ccc {}
|
||||||
|
|
||||||
pub fn debugger() string {
|
pub fn debugger() string {
|
||||||
v := B{}
|
v := Bbb{}
|
||||||
return 'Hello'
|
return 'Hello'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ enum Color {
|
||||||
yellow = 3
|
yellow = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
struct A{
|
struct Aaa{
|
||||||
color Color
|
color Color
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
col := Color.green
|
col := Color.green
|
||||||
a := A{color: col}
|
a := Aaa{color: col}
|
||||||
orange := Color.orange
|
orange := Color.orange
|
||||||
println(orange)
|
println(orange)
|
||||||
println(Color.yellow)
|
println(Color.yellow)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
A {
|
Aaa {
|
||||||
test: false
|
test: false
|
||||||
b: B {
|
b: Bbb {
|
||||||
pass: false
|
pass: false
|
||||||
name: ''
|
name: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
B {
|
Bbb {
|
||||||
pass: false
|
pass: false
|
||||||
name: ''
|
name: ''
|
||||||
}
|
}
|
|
@ -1,22 +1,22 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
struct B {
|
struct Bbb {
|
||||||
pass bool
|
pass bool
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (b &B) print() {
|
fn (b &Bbb) print() {
|
||||||
println(b)
|
println(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct A {
|
struct Aaa {
|
||||||
test bool
|
test bool
|
||||||
b B
|
b Bbb
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
println(a)
|
println(a)
|
||||||
b := B{}
|
b := Bbb{}
|
||||||
b.print()
|
b.print()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
pub mut:
|
pub mut:
|
||||||
v []int
|
v []int
|
||||||
}
|
}
|
||||||
|
|
||||||
struct B {
|
struct Bbb {
|
||||||
pub mut:
|
pub mut:
|
||||||
a []A
|
a []Aaa
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(b int, a mut []int) {
|
fn foo(b int, a mut []int) {
|
||||||
|
@ -32,8 +32,8 @@ fn test_mut() {
|
||||||
|
|
||||||
fn test_mut_2() {
|
fn test_mut_2() {
|
||||||
zero := 0
|
zero := 0
|
||||||
mut b := B{}
|
mut b := Bbb{}
|
||||||
b.a << A{}
|
b.a << Aaa{}
|
||||||
b.a[0].v = [9, 8, 7]
|
b.a[0].v = [9, 8, 7]
|
||||||
b.a[0].v << 6
|
b.a[0].v << 6
|
||||||
b.a[zero].v << 5
|
b.a[zero].v << 5
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
struct A {
|
struct Aaa {
|
||||||
foo int
|
foo int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_pointer_to_string() {
|
fn test_pointer_to_string() {
|
||||||
a := A{}
|
a := Aaa{}
|
||||||
assert a.foo.str() != (&a.foo).str()
|
assert a.foo.str() != (&a.foo).str()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
struct A { mut: v int } struct B { a A } struct C { mut: b B } struct D { mut: c C }
|
struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc }
|
||||||
mut b := B{} b = B{A{2}}
|
mut b := Bbb{} b = Bbb{Aaa{2}}
|
||||||
b.a.v = 1 // Error (field a immutable)
|
b.a.v = 1 // Error (field a immutable)
|
||||||
b.a = A{} // Error (field a immutable)
|
b.a = Aaa{} // Error (field a immutable)
|
||||||
===output===
|
===output===
|
||||||
cannot modify immutable field `a` (type `B`)
|
cannot modify immutable field `a` (type `Bbb`)
|
||||||
declare the field with `mut:`
|
declare the field with `mut:`
|
||||||
struct B {
|
struct Bbb {
|
||||||
mut:
|
mut:
|
||||||
a A
|
a Aaa
|
||||||
}
|
}
|
||||||
cannot modify immutable field `a` (type `B`)
|
cannot modify immutable field `a` (type `Bbb`)
|
||||||
declare the field with `mut:`
|
declare the field with `mut:`
|
||||||
struct B {
|
struct Bbb {
|
||||||
mut:
|
mut:
|
||||||
a A
|
a Aaa
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
struct A { mut: v int } struct B { a A } struct C { mut: b B } struct D { mut: c C }
|
struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc }
|
||||||
mut c := C{} c.b = B{}
|
mut c := Ccc{} c.b = Bbb{}
|
||||||
c.b.a = A{} // Error (field a immutable)
|
c.b.a = Aaa{} // Error (field a immutable)
|
||||||
c.b.a.v = 1 // Error (field a immutable)
|
c.b.a.v = 1 // Error (field a immutable)
|
||||||
===output===
|
===output===
|
||||||
cannot modify immutable field `a` (type `B`)
|
cannot modify immutable field `a` (type `Bbb`)
|
||||||
declare the field with `mut:`
|
declare the field with `mut:`
|
||||||
struct B {
|
struct Bbb {
|
||||||
mut:
|
mut:
|
||||||
a A
|
a Aaa
|
||||||
}
|
}
|
||||||
cannot modify immutable field `a` (type `B`)
|
cannot modify immutable field `a` (type `Bbb`)
|
||||||
declare the field with `mut:`
|
declare the field with `mut:`
|
||||||
struct B {
|
struct Bbb {
|
||||||
mut:
|
mut:
|
||||||
a A
|
a Aaa
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
struct A { mut: v int } struct B { a A } struct C { mut: b B } struct D { mut: c C }
|
struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc }
|
||||||
c2 := C{}
|
c2 := Ccc{}
|
||||||
c2.b = B{} // Error (c2 immutable)
|
c2.b = Bbb{} // Error (c2 immutable)
|
||||||
===output===
|
===output===
|
||||||
`c2` is immutable
|
`c2` is immutable
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
struct A { mut: v int } struct B { a A } struct C { mut: b B } struct D { mut: c C }
|
struct Aaa { mut: v int } struct Bbb { a Aaa } struct Ccc { mut: b Bbb } struct Ddd { mut: c Ccc }
|
||||||
mut d := D{} d.c.b = B{}
|
mut d := Ddd{} d.c.b = Bbb{}
|
||||||
'OK'
|
'OK'
|
||||||
===output===
|
===output===
|
||||||
OK
|
OK
|
||||||
|
|
|
@ -126,17 +126,17 @@ fn test_utf8_string_interpolation() {
|
||||||
assert '>${g:-13}<' == '>Πελοπόννησος <'
|
assert '>${g:-13}<' == '>Πελοπόννησος <'
|
||||||
}
|
}
|
||||||
|
|
||||||
struct S {
|
struct Sss {
|
||||||
v1 int
|
v1 int
|
||||||
v2 f64
|
v2 f64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s S) str() string {
|
fn (s Sss) str() string {
|
||||||
return '[${s.v1}, ${s.v2:.3f}]'
|
return '[${s.v1}, ${s.v2:.3f}]'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_string_interpolation_str_evaluation() {
|
fn test_string_interpolation_str_evaluation() {
|
||||||
mut x := S{17, 13.455893}
|
mut x := Sss{17, 13.455893}
|
||||||
assert '$x' == '[17, 13.456]'
|
assert '$x' == '[17, 13.456]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue