1
0
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:
Felipe Pena 2023-06-05 10:45:44 -03:00 committed by GitHub
parent 48c256bf3b
commit 169627722a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -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 {
fn_body.write_string('tos4((byteptr)${func})')
} 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>") : '
}
// eprintln('>>> caller_should_free: ${caller_should_free:6s} | funcprefix: $funcprefix | func: $func')

View 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?)
}