v/vlib/compiler/tests/repl/immutable_len_fields.repl

31 lines
564 B
Plaintext
Raw Normal View History

mut s := 'hello world'
s.len = 0 // Error (field len immutable)
mut a := []string
a.len = 0 // Error (field len immutable)
mut ints := []int
ints.len = 0 // Error (field len immutable)
println('BYE')
===output===
2019-11-13 18:39:58 +01:00
cannot modify immutable field `len` (type `string`)
declare the field with `mut:`
struct string {
2019-12-18 02:59:42 +01:00
mut:
len int
}
2019-11-13 18:39:58 +01:00
cannot modify immutable field `len` (type `array`)
declare the field with `mut:`
struct array {
2019-12-18 02:59:42 +01:00
mut:
len int
}
2019-11-13 18:39:58 +01:00
cannot modify immutable field `len` (type `array`)
declare the field with `mut:`
struct array {
2019-12-18 02:59:42 +01:00
mut:
len int
}
BYE