Skip to content

Commit

Permalink
fix: pop void tags when { is detected, update invalid files
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Jun 15, 2024
1 parent 2c97326 commit 7218cf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
examples/svelte/packages/svelte/tests/compiler-errors/samples/empty-classname-binding/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/empty-directive-name/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/illegal-expression/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/invalid-snippet-binding/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/raw-mustaches-whitespace/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/script-unclosed/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/script-unclosed-eof/main.svelte
Expand All @@ -91,6 +92,8 @@ jobs:
examples/svelte/packages/svelte/tests/compiler-errors/samples/svelte-selfdestructive/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/then-before-closing/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/then-without-await/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unbalanced-curly-component/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unbalanced-curly-element/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unclosed-attribute-self-close-tag/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input/main.svelte
examples/svelte/packages/svelte/tests/compiler-errors/samples/unexpected-end-of-input-b/main.svelte
Expand Down
6 changes: 3 additions & 3 deletions src/scanner.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "tag.h"
#include "tree_sitter/parser.h"

#include <stdio.h>
#include <wctype.h>

enum TokenType {
Expand Down Expand Up @@ -283,7 +282,7 @@ static bool scan_implicit_end_tag(Scanner *scanner, TSLexer *lexer) {
}

// Otherwise, dig deeper and queue implicit end tags (to be nice in
// the case of malformed svelte)
// the case of malformed Svelte)
for (unsigned i = scanner->tags.size; i > 0; i--) {
if (scanner->tags.contents[i - 1].type == next_tag.type) {
pop_tag(scanner);
Expand Down Expand Up @@ -355,7 +354,7 @@ static bool scan_self_closing_tag_delimiter(Scanner *scanner, TSLexer *lexer) {
if (lexer->lookahead == '>') {
advance(lexer);
if (scanner->tags.size > 0) {
tag_free(&array_pop(&scanner->tags));
pop_tag(scanner);
lexer->result_symbol = SELF_CLOSING_TAG_DELIMITER;
}
return true;
Expand Down Expand Up @@ -391,6 +390,7 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
}
break;

case '{':
case '\0':
if (valid_symbols[IMPLICIT_END_TAG]) {
return scan_implicit_end_tag(scanner, lexer);
Expand Down

0 comments on commit 7218cf6

Please sign in to comment.