From ae61ae21ec7c303186e3dc60fd7e87fe468b9158 Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Thu, 11 May 2023 13:04:17 -0700 Subject: [PATCH] Fix incorrectly set end locations for DeclareComponent and ComponentTypeAnnotation Summary: The `DeclareComponent` and `ComponentTypeAnnotation` nodes were incorrectly setting their end loc as `tok_->getEndLoc()` (the end of the current token) instead of `getPrevTokenEndLoc()` (the end of the node). Reviewed By: avp Differential Revision: D45594191 fbshipit-source-id: 57ce7d54ab0cf5442a6d8813ccf230447feb109c --- lib/Parser/JSParserImpl-flow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Parser/JSParserImpl-flow.cpp b/lib/Parser/JSParserImpl-flow.cpp index a8ace2c6e01..3fc016e7b54 100644 --- a/lib/Parser/JSParserImpl-flow.cpp +++ b/lib/Parser/JSParserImpl-flow.cpp @@ -225,7 +225,7 @@ Optional JSParserImpl::parseComponentDeclarationFlow( return setLocation( start, - tok_->getEndLoc(), + getPrevTokenEndLoc(), new (context_) ESTree::DeclareComponentNode( *optId, std::move(paramList), rest, typeParams, returnType)); } @@ -458,7 +458,7 @@ Optional JSParserImpl::parseComponentTypeAnnotationFlow() { return setLocation( start, - tok_->getEndLoc(), + getPrevTokenEndLoc(), new (context_) ESTree::ComponentTypeAnnotationNode( std::move(paramList), rest, typeParams, returnType)); }