mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: circular reference limit to auto_str for interface (#18340)
This commit is contained in:
parent
48c256bf3b
commit
169627722a
@ -1007,7 +1007,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin
|
|||||||
if field.typ in ast.charptr_types {
|
if field.typ in ast.charptr_types {
|
||||||
fn_body.write_string('tos4((byteptr)${func})')
|
fn_body.write_string('tos4((byteptr)${func})')
|
||||||
} else {
|
} else {
|
||||||
if field.typ.is_ptr() && sym.kind == .struct_ {
|
if field.typ.is_ptr() && sym.kind in [.struct_, .interface_] {
|
||||||
funcprefix += '(indent_count > 25)? _SLIT("<probably circular>") : '
|
funcprefix += '(indent_count > 25)? _SLIT("<probably circular>") : '
|
||||||
}
|
}
|
||||||
// eprintln('>>> caller_should_free: ${caller_should_free:6s} | funcprefix: $funcprefix | func: $func')
|
// eprintln('>>> caller_should_free: ${caller_should_free:6s} | funcprefix: $funcprefix | func: $func')
|
||||||
|
18
vlib/v/tests/option_ptr_iface_test.v
Normal file
18
vlib/v/tests/option_ptr_iface_test.v
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
interface ITeste {
|
||||||
|
mut:
|
||||||
|
teste ?&ITeste
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Teste {
|
||||||
|
pub mut:
|
||||||
|
teste ?&ITeste
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
mut t := Teste{}
|
||||||
|
t.teste = &t
|
||||||
|
z := &ITeste(t)
|
||||||
|
dump(z)
|
||||||
|
dump(t)
|
||||||
|
assert voidptr(t.teste?) == voidptr(z.teste?)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user