mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix printing and dumping of struct having referenced interface as field (#15765)
This commit is contained in:
parent
566a61b136
commit
f09197b972
@ -921,7 +921,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, styp string, str_fn_name stri
|
|||||||
funcprefix += 'isnil(it.${c_name(field.name)})'
|
funcprefix += 'isnil(it.${c_name(field.name)})'
|
||||||
funcprefix += ' ? _SLIT("nil") : '
|
funcprefix += ' ? _SLIT("nil") : '
|
||||||
// struct, floats and ints have a special case through the _str function
|
// struct, floats and ints have a special case through the _str function
|
||||||
if sym.kind !in [.struct_, .alias, .enum_] && !field.typ.is_int_valptr()
|
if sym.kind !in [.struct_, .alias, .enum_, .interface_] && !field.typ.is_int_valptr()
|
||||||
&& !field.typ.is_float_valptr() {
|
&& !field.typ.is_float_valptr() {
|
||||||
funcprefix += '*'
|
funcprefix += '*'
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,32 @@
|
|||||||
[vlib/v/tests/inout/dump_expression.vv:4] 1: 1
|
[vlib/v/tests/inout/dump_expression.vv:5] 1: 1
|
||||||
[vlib/v/tests/inout/dump_expression.vv:9] 'a': a
|
[vlib/v/tests/inout/dump_expression.vv:10] 'a': a
|
||||||
[vlib/v/tests/inout/dump_expression.vv:25] p: Point{
|
[vlib/v/tests/inout/dump_expression.vv:32] a: Aa{
|
||||||
|
log: &log.Logger(log.Log{
|
||||||
|
level: disabled
|
||||||
|
output_label: ''
|
||||||
|
ofile: os.File{
|
||||||
|
cfile: 0
|
||||||
|
fd: 0
|
||||||
|
is_opened: false
|
||||||
|
}
|
||||||
|
output_target: console
|
||||||
|
output_file_name: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
[vlib/v/tests/inout/dump_expression.vv:33] p: Point{
|
||||||
x: 1
|
x: 1
|
||||||
y: 2
|
y: 2
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
[vlib/v/tests/inout/dump_expression.vv:26] p_mut: Point{
|
[vlib/v/tests/inout/dump_expression.vv:34] p_mut: Point{
|
||||||
x: 1
|
x: 1
|
||||||
y: 2
|
y: 2
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
[vlib/v/tests/inout/dump_expression.vv:27] p_ptr: &Point{
|
[vlib/v/tests/inout/dump_expression.vv:35] p_ptr: &Point{
|
||||||
x: 1
|
x: 1
|
||||||
y: 2
|
y: 2
|
||||||
z: 3
|
z: 3
|
||||||
}
|
}
|
||||||
[vlib/v/tests/inout/dump_expression.vv:38] os.file_name(vfile): dump_expression.vv
|
[vlib/v/tests/inout/dump_expression.vv:46] os.file_name(vfile): dump_expression.vv
|
||||||
[vlib/v/tests/inout/dump_expression.vv:41] f.read(mut buf): 10
|
[vlib/v/tests/inout/dump_expression.vv:49] f.read(mut buf): 10
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import log
|
||||||
|
|
||||||
fn dump_of_int() {
|
fn dump_of_int() {
|
||||||
x := dump(1) + 1
|
x := dump(1) + 1
|
||||||
@ -17,11 +18,18 @@ mut:
|
|||||||
z int
|
z int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Aa{
|
||||||
|
log &log.Logger
|
||||||
|
}
|
||||||
|
|
||||||
fn dump_of_struct() {
|
fn dump_of_struct() {
|
||||||
p := Point{1, 2, 3}
|
p := Point{1, 2, 3}
|
||||||
mut p_mut := Point{1, 2, 3}
|
mut p_mut := Point{1, 2, 3}
|
||||||
p_ptr := &Point{1, 2, 3}
|
p_ptr := &Point{1, 2, 3}
|
||||||
|
l := &log.Log{}
|
||||||
|
a := Aa{log:l}
|
||||||
|
|
||||||
|
dump(a)
|
||||||
mut x1 := dump(p)
|
mut x1 := dump(p)
|
||||||
mut x2 := dump(p_mut)
|
mut x2 := dump(p_mut)
|
||||||
mut x3 := dump(p_ptr)
|
mut x3 := dump(p_ptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user