Skip to content

Commit

Permalink
checker: fix typeof of typeof.name (vlang#19323)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp authored Sep 10, 2023
1 parent d275af2 commit 81b30ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/gen/c/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ fn (mut g Gen) get_comptime_var_type(node ast.Expr) ast.Type {
fn (mut g Gen) resolve_comptime_type(node ast.Expr, default_type ast.Type) ast.Type {
if (node is ast.Ident && g.is_comptime_var(node)) || node is ast.ComptimeSelector {
return g.get_comptime_var_type(node)
} else if node is ast.SelectorExpr {
} else if node is ast.SelectorExpr && node.expr_type != 0 {
sym := g.table.sym(g.unwrap_generic(node.expr_type))
if f := g.table.find_field_with_embeds(sym, node.field_name) {
return f.typ
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/tests/typeof_name_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn test_main() {
pi := 3.14
type_ := typeof(pi).name
assert typeof(type_).name == 'string'
assert typeof(typeof(pi).name).name == 'string'
}

0 comments on commit 81b30ca

Please sign in to comment.