Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 27, 2024
1 parent d6da5b3 commit 5278248
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion vlib/v/checker/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) ast.Type {
c.error('no known default format for type `${c.table.get_type_name(ftyp)}`',
node.fmt_poss[i])
}
} else if c.comptime.is_comptime(expr) && c.comptime.get_type(expr) != ast.void_type {
} else if c.comptime.is_comptime(expr)
&& c.comptime.get_type_or_default(expr, ast.void_type) != ast.void_type {
// still `_` placeholder for comptime variable without specifier
node.need_fmts[i] = false
} else {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/c/str_intp.v
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn (mut g Gen) string_inter_literal(node ast.StringInterLiteral) {
mut fmts := node_.fmts.clone()
for i, mut expr in node_.exprs {
if g.comptime.is_comptime(expr) {
ctyp := g.comptime.get_type(expr)
ctyp := g.comptime.get_type_or_default(expr, node_.expr_types[i])
if ctyp != ast.void_type {
node_.expr_types[i] = ctyp
if node_.fmts[i] == `_` {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/tests/generics/generics_method_str_overload_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Gen[G] {
}

fn (g Gen[G]) str() string {
return 'Gen<${G.name}>{${g.id}, ${g.data.str()}, ${g.size}}'
return 'Gen<${G.name}>{${g.id}, ${g.data}, ${g.size}}'
}

fn test_generics_method_str_overload() {
Expand Down

0 comments on commit 5278248

Please sign in to comment.