diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 2d5c85d902..43b9952c15 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -258,6 +258,7 @@ pub: pub mut: name string is_method bool + is_field bool // temp hack, remove ASAP when call repimpl CallExpr / Selector (joe) args []CallArg expected_arg_types []table.Type language table.Language diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 73fec9cc86..c6c9c75462 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -977,7 +977,8 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type { if field := c.table.struct_find_field(left_type_sym, method_name) { field_type_sym := c.table.get_type_symbol(field.typ) if field_type_sym.kind == .function { - call_expr.is_method = false + // call_expr.is_method = false + call_expr.is_field = true info := field_type_sym.info as table.FnType call_expr.return_type = info.func.return_type // TODO: check args (do it once for all of the above) diff --git a/vlib/v/gen/fn.v b/vlib/v/gen/fn.v index 415ac23519..c3abc77f11 100644 --- a/vlib/v/gen/fn.v +++ b/vlib/v/gen/fn.v @@ -269,7 +269,7 @@ fn (mut g Gen) call_expr(node ast.CallExpr) { styp := g.typ(node.return_type.set_flag(.optional)) g.write('$styp $tmp_opt = ') } - if node.is_method { + if node.is_method && !node.is_field { if node.name == 'writeln' && g.pref.show_cc && node.args.len > 0 && node.args[0].expr is ast.StringInterLiteral && g.table.get_type_symbol(node.receiver_type).name == 'strings.Builder' {