From 912c8bad38e9564e2f7cfd2afd0c578bd28cda49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vlas=C3=A1k?= Date: Wed, 4 Mar 2020 16:34:10 +0100 Subject: [PATCH] Add check for binding non-writable variables --- src/compiler/compile/nodes/Binding.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/compile/nodes/Binding.ts b/src/compiler/compile/nodes/Binding.ts index 7d6fad0a81..4028ad699b 100644 --- a/src/compiler/compile/nodes/Binding.ts +++ b/src/compiler/compile/nodes/Binding.ts @@ -72,6 +72,11 @@ export default class Binding extends Node { }); variable[this.expression.node.type === 'MemberExpression' ? 'mutated' : 'reassigned'] = true; + + if (!variable.writable) component.error(this.expression.node, { + code: 'invalid-binding', + message: 'Cannot bind to a variable which is not writable', + }); } const type = parent.get_static_attribute_value('type');