From 2f47d41f2b676d645239189745d88df96a70f6d2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 9 Mar 2020 23:35:42 -0400 Subject: [PATCH] Fix tagged template start to include tag (#714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 강동윤 --- ecmascript/parser/Cargo.toml | 2 +- ecmascript/parser/src/parser/expr.rs | 5 ++--- .../type-arguments/tagged-template-no-asi/input.ts.json | 2 +- .../typescript/type-arguments/tagged-template/input.ts.json | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index 11d457c5bb5..72141c351fa 100644 --- a/ecmascript/parser/Cargo.toml +++ b/ecmascript/parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swc_ecma_parser" -version = "0.21.1" +version = "0.21.2" authors = ["강동윤 "] license = "Apache-2.0/MIT" repository = "https://github.com/swc-project/swc.git" diff --git a/ecmascript/parser/src/parser/expr.rs b/ecmascript/parser/src/parser/expr.rs index bccf23e72ce..ef813e1368f 100644 --- a/ecmascript/parser/src/parser/expr.rs +++ b/ecmascript/parser/src/parser/expr.rs @@ -776,9 +776,8 @@ impl<'a, I: Tokens> Parser<'a, I> { tag: Box, type_params: Option, ) -> PResult<'a, TaggedTpl> { - let start = tag.span().lo(); + let tagged_tpl_start = tag.span().lo(); trace_cur!(parse_tagged_tpl); - let start = cur_pos!(); assert_and_bump!('`'); @@ -786,7 +785,7 @@ impl<'a, I: Tokens> Parser<'a, I> { expect!('`'); - let span = span!(start); + let span = span!(tagged_tpl_start); Ok(TaggedTpl { span, tag, diff --git a/ecmascript/parser/tests/typescript/type-arguments/tagged-template-no-asi/input.ts.json b/ecmascript/parser/tests/typescript/type-arguments/tagged-template-no-asi/input.ts.json index a7311dda1d4..7f1e61554c1 100644 --- a/ecmascript/parser/tests/typescript/type-arguments/tagged-template-no-asi/input.ts.json +++ b/ecmascript/parser/tests/typescript/type-arguments/tagged-template-no-asi/input.ts.json @@ -23,7 +23,7 @@ "callee": { "type": "TaggedTemplateExpression", "span": { - "start": 9, + "start": 4, "end": 11, "ctxt": 0 }, diff --git a/ecmascript/parser/tests/typescript/type-arguments/tagged-template/input.ts.json b/ecmascript/parser/tests/typescript/type-arguments/tagged-template/input.ts.json index 4d6e48edfa6..ff68e714a12 100644 --- a/ecmascript/parser/tests/typescript/type-arguments/tagged-template/input.ts.json +++ b/ecmascript/parser/tests/typescript/type-arguments/tagged-template/input.ts.json @@ -16,7 +16,7 @@ "expression": { "type": "TaggedTemplateExpression", "span": { - "start": 4, + "start": 0, "end": 6, "ctxt": 0 },