Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/six-lemons-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: throw on invalid `{@tag}`s
6 changes: 6 additions & 0 deletions documentation/docs/98-reference/.generated/compile-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ Expected an identifier
Expected identifier or destructure pattern
```

### expected_tag

```
Expected 'html', 'render', 'attach', 'const', or 'debug'
```

### expected_token

```
Expand Down
4 changes: 4 additions & 0 deletions packages/svelte/messages/compile-errors/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ The same applies to components:

> Expected identifier or destructure pattern

## expected_tag

> Expected 'html', 'render', 'attach', 'const', or 'debug'

## expected_token

> Expected token %token%
Expand Down
9 changes: 9 additions & 0 deletions packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,15 @@ export function expected_pattern(node) {
e(node, 'expected_pattern', `Expected identifier or destructure pattern\nhttps://svelte.dev/e/expected_pattern`);
}

/**
* Expected 'html', 'render', 'attach', 'const', or 'debug'
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function expected_tag(node) {
e(node, 'expected_tag', `Expected 'html', 'render', 'attach', 'const', or 'debug'\nhttps://svelte.dev/e/expected_tag`);
}

/**
* Expected token %token%
* @param {null | number | NodeLike} node
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte/src/compiler/phases/1-parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ function special(parser) {
expression: new ExpressionMetadata()
}
});
return;
}

if (parser.eat('render')) {
Expand Down Expand Up @@ -755,5 +756,7 @@ function special(parser) {
snippets: new Set()
}
});
return;
}
e.expected_tag(parser.index);
}
Loading