File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3898,7 +3898,7 @@ fn (mut c Checker) map_builtin_method_call(mut node ast.CallExpr, left_type_ ast
38983898// is `array_xxx`, instead of the plain `array` .
38993899fn (mut c Checker) ensure_same_array_return_type (mut node ast.CallExpr, left_type ast.Type) {
39003900 node.receiver_type = left_type.ref ()
3901- if node.left.is_auto_deref_var () {
3901+ if node.left.is_auto_deref_var () && left_type. nr_muls () > 0 {
39023902 node.return_type = left_type.deref ()
39033903 } else {
39043904 node.return_type = node.receiver_type.set_nr_muls (0 )
Original file line number Diff line number Diff line change @@ -7052,6 +7052,14 @@ fn (mut g Gen) ident(node ast.Ident) {
70527052 if node.obj is ast.Var {
70537053 is_auto_heap = g.resolved_ident_is_auto_heap (node)
70547054 && (! g.is_assign_lhs || g.assign_op != .decl_assign)
7055+ // When a variable is both auto_heap and auto_deref (e.g. a `mut`
7056+ // parameter of a @[heap] struct), the pointer indirection is
7057+ // already handled by the auto_deref mechanism (-> for selectors,
7058+ // pointer-type tracking in calls). Adding (*(…)) would
7059+ // incorrectly dereference the pointer a second time.
7060+ if is_auto_heap && node.obj.is_auto_deref {
7061+ is_auto_heap = false
7062+ }
70557063 if is_auto_heap && (node.obj.typ.has_flag (.generic)
70567064 || g.type_has_unresolved_generic_parts (node.obj.typ)) {
70577065 resolved_obj_typ := g.unwrap_generic (node.obj.typ)
You can’t perform that action at this time.
0 commit comments