From 7218cf622b057ae9c530e1f0a7a3ce49806ca55e Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 15 Jun 2024 13:28:13 -0400 Subject: [PATCH] fix: pop void tags when `{` is detected, update invalid files --- .github/workflows/ci.yml | 3 +++ src/scanner.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69f20b8..d95db67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/src/scanner.c b/src/scanner.c index 7e76322..75c88ac 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1,7 +1,6 @@ #include "tag.h" #include "tree_sitter/parser.h" -#include #include enum TokenType { @@ -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); @@ -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; @@ -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);