Skip to content

Commit 4cb3335

Browse files
committed
fail on generators
1 parent d92bd8a commit 4cb3335

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

documentation/docs/98-reference/.generated/compile-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,12 @@ Expected whitespace
442442
Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
443443
```
444444

445+
### inspect_trace_generator
446+
447+
```
448+
`$inspect.trace(...)` cannot be used inside a generator function
449+
```
450+
445451
### inspect_trace_invalid_placement
446452

447453
```

packages/svelte/messages/compile-errors/script.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454

5555
> Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
5656
57+
## inspect_trace_generator
58+
59+
> `$inspect.trace(...)` cannot be used inside a generator function
60+
5761
## inspect_trace_invalid_placement
5862

5963
> `$inspect.trace(...)` must be the first statement of a function body

packages/svelte/src/compiler/errors.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ export function inspect_trace_invalid_placement(node) {
215215
e(node, "inspect_trace_invalid_placement", `\`$inspect.trace(...)\` must be the first statement of a function body\nhttps://svelte.dev/e/inspect_trace_invalid_placement`);
216216
}
217217

218+
/**
219+
* `$inspect.trace(...)` cannot be used inside a generator function
220+
* @param {null | number | NodeLike} node
221+
* @returns {never}
222+
*/
223+
export function inspect_trace_generator(node) {
224+
e(node, "inspect_trace_generator", `\`$inspect.trace(...)\` cannot be used inside a generator function\nhttps://svelte.dev/e/inspect_trace_generator`);
225+
}
226+
218227
/**
219228
* The arguments keyword cannot be used within the template or at the top level of a component
220229
* @param {null | number | NodeLike} node

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ export function CallExpression(node, context) {
158158
e.inspect_trace_invalid_placement(node);
159159
}
160160

161+
if (fn.generator) {
162+
e.inspect_trace_generator(node);
163+
}
164+
161165
if (dev) {
162166
if (node.arguments[0]) {
163167
context.state.scope.tracing = b.thunk(/** @type {Expression} */ (node.arguments[0]));

0 commit comments

Comments
 (0)