mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix printing for mut v in arr (#17137)
This commit is contained in:
parent
b732dd6816
commit
d3e4058aec
@ -16,6 +16,9 @@ fn (mut g Gen) str_format(node ast.StringInterLiteral, i int) (u64, string) {
|
||||
mut base := 0 // numeric base
|
||||
mut upper_case := false // set upercase for the result string
|
||||
mut typ := g.unwrap_generic(node.expr_types[i])
|
||||
if node.exprs[i].is_auto_deref_var() {
|
||||
typ = typ.deref()
|
||||
}
|
||||
sym := g.table.sym(typ)
|
||||
|
||||
if sym.kind == .alias {
|
||||
|
4
vlib/v/slow_tests/inout/printing_for_mut_v_in_a.out
Normal file
4
vlib/v/slow_tests/inout/printing_for_mut_v_in_a.out
Normal file
@ -0,0 +1,4 @@
|
||||
mutable num is 255
|
||||
imutable element is 255
|
||||
mutable element is 255
|
||||
mutable element is 255
|
21
vlib/v/slow_tests/inout/printing_for_mut_v_in_a.vv
Normal file
21
vlib/v/slow_tests/inout/printing_for_mut_v_in_a.vv
Normal file
@ -0,0 +1,21 @@
|
||||
fn main() {
|
||||
// check to see if mutable integers work as expected
|
||||
mut num := 255
|
||||
println('mutable num is ${num}')
|
||||
|
||||
mut arr := [255]
|
||||
// check to see if mutable arrays with immutable iteration work as expected
|
||||
for elem in arr {
|
||||
println('imutable element is ${elem}')
|
||||
}
|
||||
|
||||
// check to see if mutable arrays with mutable iteration work as expected
|
||||
for mut elem in arr {
|
||||
println('mutable element is ${elem}')
|
||||
}
|
||||
|
||||
// check to see if mutable arrays with mutable iteration work as expected (explicit format)
|
||||
for mut elem in arr {
|
||||
println('mutable element is ${elem:d}')
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user