From b720bb2e778174f355a3f6fce2c55668fd220f5e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 6 Nov 2019 06:48:57 +0300 Subject: [PATCH] parser: mark var as changed only if the receiver is mutable --- vlib/compiler/fn.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index 63e952312a..19d3bfb79b 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -727,7 +727,7 @@ fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type s p.error('`$p.expr_var.name` is immutable, declare it with `mut`') } } - if !p.expr_var.is_changed { + if !p.expr_var.is_changed && receiver.is_mut { p.mark_var_changed(p.expr_var) } p.gen_method_call(receiver, receiver_type, cgen_name, f.typ, method_ph)