diff --git a/src/compiler/compile/nodes/Binding.ts b/src/compiler/compile/nodes/Binding.ts
index 28e6af5aa19d..7d6fad0a816a 100644
--- a/src/compiler/compile/nodes/Binding.ts
+++ b/src/compiler/compile/nodes/Binding.ts
@@ -50,6 +50,13 @@ export default class Binding extends Node {
message: 'Cannot bind to a variable declared with the let: directive'
});
} else if (this.is_contextual) {
+ if (scope.is_await(name)) {
+ component.error(this, {
+ code: 'invalid-binding',
+ message: 'Cannot bind to a variable declared with {#await ... then} or {:catch} blocks'
+ });
+ }
+
scope.dependencies_for_name.get(name).forEach(name => {
const variable = component.var_lookup.get(name);
if (variable) {
diff --git a/src/compiler/compile/nodes/shared/TemplateScope.ts b/src/compiler/compile/nodes/shared/TemplateScope.ts
index 5f30d0c88370..4e087eedf5d5 100644
--- a/src/compiler/compile/nodes/shared/TemplateScope.ts
+++ b/src/compiler/compile/nodes/shared/TemplateScope.ts
@@ -42,4 +42,9 @@ export default class TemplateScope {
const owner = this.get_owner(name);
return owner && (owner.type === 'Element' || owner.type === 'InlineComponent');
}
+
+ is_await(name: string) {
+ const owner = this.get_owner(name);
+ return owner && (owner.type === 'ThenBlock' || owner.type === 'CatchBlock');
+ }
}
diff --git a/test/validator/samples/binding-await-catch/errors.json b/test/validator/samples/binding-await-catch/errors.json
new file mode 100644
index 000000000000..00141686f385
--- /dev/null
+++ b/test/validator/samples/binding-await-catch/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 79,
+ "start": { "line": 6, "column": 9, "character": 79 },
+ "end": { "line": 6, "column": 27, "character": 97 }
+ }
+]
diff --git a/test/validator/samples/binding-await-catch/input.svelte b/test/validator/samples/binding-await-catch/input.svelte
new file mode 100644
index 000000000000..b640f6305bdd
--- /dev/null
+++ b/test/validator/samples/binding-await-catch/input.svelte
@@ -0,0 +1,7 @@
+
+{#await promise}
+{:catch error}
+
+{/await}
diff --git a/test/validator/samples/binding-await-then-2/errors.json b/test/validator/samples/binding-await-then-2/errors.json
new file mode 100644
index 000000000000..e734ed4717f7
--- /dev/null
+++ b/test/validator/samples/binding-await-then-2/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 78,
+ "start": { "line": 6, "column": 9, "character": 78 },
+ "end": { "line": 6, "column": 19, "character": 88 }
+ }
+]
diff --git a/test/validator/samples/binding-await-then-2/input.svelte b/test/validator/samples/binding-await-then-2/input.svelte
new file mode 100644
index 000000000000..e8c56c8e0b2c
--- /dev/null
+++ b/test/validator/samples/binding-await-then-2/input.svelte
@@ -0,0 +1,7 @@
+
+{#await promise}
+{:then value}
+
+{/await}
diff --git a/test/validator/samples/binding-await-then/errors.json b/test/validator/samples/binding-await-then/errors.json
new file mode 100644
index 000000000000..a611e7731f19
--- /dev/null
+++ b/test/validator/samples/binding-await-then/errors.json
@@ -0,0 +1,9 @@
+[
+ {
+ "code": "invalid-binding",
+ "message": "Cannot bind to a variable declared with {#await ... then} or {:catch} blocks",
+ "pos": 75,
+ "start": { "line": 5, "column": 9, "character": 75 },
+ "end": { "line": 5, "column": 19, "character": 85 }
+ }
+]
diff --git a/test/validator/samples/binding-await-then/input.svelte b/test/validator/samples/binding-await-then/input.svelte
new file mode 100644
index 000000000000..bc55ef97e464
--- /dev/null
+++ b/test/validator/samples/binding-await-then/input.svelte
@@ -0,0 +1,6 @@
+
+{#await promise then value}
+
+{/await}