Skip to content

Commit 2d127bc

Browse files
committed
markused: keep str_intp for aliases whose codegen wraps parent str()
When a `type Foo = Bar` alias has no str method of its own but its parent type does, cgen emits a wrapper `indent_Foo_str` that calls `builtin__str_intp` to format `'Foo(...)'` around the parent's str output (auto_str_methods.v gen_str_for_alias). type_auto_str_needs_str_intp was unaliasing first and seeing the parent's str method, so it returned false and -skip-unused dropped str_intp / StrIntpData, producing `implicit declaration of function 'builtin__str_intp'` for any program that just calls .str() on an SDL Version (and other c2v-style aliases). Check the pre-unaliased sym for the Alias-without-own-str case before falling through to the unaliased-parent-has-str shortcut.
1 parent a069b12 commit 2d127bc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

vlib/v/markused/walker.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,6 +2842,10 @@ fn (mut w Walker) type_auto_str_needs_str_intp(typ ast.Type) bool {
28422842
if resolved_typ.is_ptr() || resolved_typ.is_pointer() {
28432843
return true
28442844
}
2845+
raw_sym := w.table.sym(resolved_typ)
2846+
if raw_sym.info is ast.Alias && !raw_sym.has_method('str') {
2847+
return true
2848+
}
28452849
sym := w.table.final_sym(w.table.unaliased_type(resolved_typ))
28462850
if sym.has_method('str') {
28472851
return false

0 commit comments

Comments
 (0)