v/vlib/compiler/tests/repl/immutable_len_fields.repl
Alexander Medvednikov 7456d556e1 fix 2 repl tests
2019-12-18 05:02:23 +03:00

30 lines
564 B
Text

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===
cannot modify immutable field `len` (type `string`)
declare the field with `mut:`
struct string {
mut:
len int
}
cannot modify immutable field `len` (type `array`)
declare the field with `mut:`
struct array {
mut:
len int
}
cannot modify immutable field `len` (type `array`)
declare the field with `mut:`
struct array {
mut:
len int
}
BYE