diff --git a/src/compiler/compile/nodes/Binding.ts b/src/compiler/compile/nodes/Binding.ts
index 7d6fad0a81..2f199709c8 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 (info.expression.type === 'Identifier' && !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');
diff --git a/test/validator/samples/binding-const-field/errors.json b/test/validator/samples/binding-const-field/errors.json
new file mode 100644
index 0000000000..fe51488c70
--- /dev/null
+++ b/test/validator/samples/binding-const-field/errors.json
@@ -0,0 +1 @@
+[]
diff --git a/test/validator/samples/binding-const-field/input.svelte b/test/validator/samples/binding-const-field/input.svelte
new file mode 100644
index 0000000000..055a16438d
--- /dev/null
+++ b/test/validator/samples/binding-const-field/input.svelte
@@ -0,0 +1,7 @@
+
+
+
diff --git a/test/validator/samples/binding-const/errors.json b/test/validator/samples/binding-const/errors.json
new file mode 100644
index 0000000000..6d48af9c4e
--- /dev/null
+++ b/test/validator/samples/binding-const/errors.json
@@ -0,0 +1,15 @@
+[{
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable which is not writable",
+ "pos": 61,
+ "start": {
+ "line": 5,
+ "column": 19,
+ "character": 61
+ },
+ "end": {
+ "line": 5,
+ "column": 24,
+ "character": 66
+ }
+}]
\ No newline at end of file
diff --git a/test/validator/samples/binding-const/input.svelte b/test/validator/samples/binding-const/input.svelte
new file mode 100644
index 0000000000..1857a1932c
--- /dev/null
+++ b/test/validator/samples/binding-const/input.svelte
@@ -0,0 +1,5 @@
+
+
+