diff --git a/vlib/v/gen/c/comptime.v b/vlib/v/gen/c/comptime.v index 7491fd3fc31625..877b095ee5cad2 100644 --- a/vlib/v/gen/c/comptime.v +++ b/vlib/v/gen/c/comptime.v @@ -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 diff --git a/vlib/v/tests/typeof_name_test.v b/vlib/v/tests/typeof_name_test.v new file mode 100644 index 00000000000000..6cc7472230aaf0 --- /dev/null +++ b/vlib/v/tests/typeof_name_test.v @@ -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' +}