| ... | ... | @@ -339,6 +339,8 @@ pub const ResultInfo = struct { |
| 339 | 339 | fn_arg, |
| 340 | 340 | /// The expression is the right-hand side of an initializer for a `const` variable |
| 341 | 341 | const_init, |
| 342 | /// The expression is the right-hand side of an assignment expression. |
| 343 | assignment, |
| 342 | 344 | /// No specific operator in particular. |
| 343 | 345 | none, |
| 344 | 346 | }; |
| ... | ... | @@ -3216,7 +3218,7 @@ fn assign(gz: *GenZir, scope: *Scope, infix_node: Ast.Node.Index) InnerError!voi |
| 3216 | 3218 | // This intentionally does not support `@"_"` syntax. |
| 3217 | 3219 | const ident_name = tree.tokenSlice(main_tokens[lhs]); |
| 3218 | 3220 | if (mem.eql(u8, ident_name, "_")) { |
| 3219 | | _ = try expr(gz, scope, .{ .rl = .discard }, rhs); |
| 3221 | _ = try expr(gz, scope, .{ .rl = .discard, .ctx = .assignment }, rhs); |
| 3220 | 3222 | return; |
| 3221 | 3223 | } |
| 3222 | 3224 | } |
| ... | ... | @@ -7088,7 +7090,7 @@ fn localVarRef( |
| 7088 | 7090 | if (local_val.name == name_str_index) { |
| 7089 | 7091 | // Locals cannot shadow anything, so we do not need to look for ambiguous |
| 7090 | 7092 | // references in this case. |
| 7091 | | if (ri.rl == .discard) { |
| 7093 | if (ri.rl == .discard and ri.ctx == .assignment) { |
| 7092 | 7094 | local_val.discarded = ident_token; |
| 7093 | 7095 | } else { |
| 7094 | 7096 | local_val.used = ident_token; |
| ... | ... | @@ -7111,7 +7113,7 @@ fn localVarRef( |
| 7111 | 7113 | .local_ptr => { |
| 7112 | 7114 | const local_ptr = s.cast(Scope.LocalPtr).?; |
| 7113 | 7115 | if (local_ptr.name == name_str_index) { |
| 7114 | | if (ri.rl == .discard) { |
| 7116 | if (ri.rl == .discard and ri.ctx == .assignment) { |
| 7115 | 7117 | local_ptr.discarded = ident_token; |
| 7116 | 7118 | } else { |
| 7117 | 7119 | local_ptr.used = ident_token; |
| ... | ... | @@ -10672,14 +10674,19 @@ const GenZir = struct { |
| 10672 | 10674 | gz.break_result_info = parent_ri; |
| 10673 | 10675 | }, |
| 10674 | 10676 | |
| 10675 | | .discard, .none, .ref => { |
| 10677 | .none, .ref => { |
| 10676 | 10678 | gz.rl_ty_inst = .none; |
| 10677 | 10679 | gz.break_result_info = parent_ri; |
| 10678 | 10680 | }, |
| 10679 | 10681 | |
| 10682 | .discard => { |
| 10683 | gz.rl_ty_inst = .none; |
| 10684 | gz.break_result_info = .{ .rl = .discard }; |
| 10685 | }, |
| 10686 | |
| 10680 | 10687 | .ptr => |ptr_res| { |
| 10681 | 10688 | gz.rl_ty_inst = .none; |
| 10682 | | gz.break_result_info = .{ .rl = .{ .ptr = .{ .inst = ptr_res.inst } } }; |
| 10689 | gz.break_result_info = .{ .rl = .{ .ptr = .{ .inst = ptr_res.inst } }, .ctx = parent_ri.ctx }; |
| 10683 | 10690 | }, |
| 10684 | 10691 | |
| 10685 | 10692 | .inferred_ptr => |ptr| { |