summaryrefslogtreecommitdiff
path: root/deps/v8/src/parsing
diff options
context:
space:
mode:
authorMatheus Marchini <mmarchini@netflix.com>2020-03-10 10:45:10 -0700
committerAnna Henningsen <anna@addaleax.net>2020-03-13 17:32:58 +0100
commit75da64c0587f2925319cd9c1717a19b647b93511 (patch)
tree6262bfbc308c248969c17fb208acfaec9d21cdae /deps/v8/src/parsing
parent16cce385c0e6d1fc633e0499d70e99be561ad76f (diff)
downloadnode-new-75da64c0587f2925319cd9c1717a19b647b93511.tar.gz
deps: V8: cherry-pick f9257802c1c0
Original commit message: Fix scanner-level error reporting for hashbang When the file begins with a hashbang, the scanner is in a failed state when SkipHashbang() is called. This is usually not an issue but when the parser encounters an ILLEGAL token, it will reset the SyntaxError location because of it. Bug: v8:10110 Change-Id: I1c7344bf5ad20079cff80130c991f3bff4d7e9a8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1995312 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#66038} Refs: https://github.com/v8/v8/commit/f9257802c1c0a0663a1d05bacf662283f6bd9050 Fixes: https://github.com/nodejs/node/issues/31284 Signed-off-by: Matheus Marchini <mmarchini@netflix.com> PR-URL: https://github.com/nodejs/node/pull/32180 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/v8/src/parsing')
-rw-r--r--deps/v8/src/parsing/parser.cc1
-rw-r--r--deps/v8/src/parsing/preparser.cc4
-rw-r--r--deps/v8/src/parsing/scanner-inl.h4
-rw-r--r--deps/v8/src/parsing/scanner.cc7
-rw-r--r--deps/v8/src/parsing/scanner.h3
5 files changed, 4 insertions, 15 deletions
diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc
index edb9604bb5..a05884adc0 100644
--- a/deps/v8/src/parsing/parser.cc
+++ b/deps/v8/src/parsing/parser.cc
@@ -503,7 +503,6 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
Scope::DeserializationMode::kIncludingVariables);
scanner_.Initialize();
- scanner_.SkipHashBang();
FunctionLiteral* result = DoParseProgram(isolate, info);
MaybeResetCharacterStream(info, result);
MaybeProcessSourceRanges(info, result, stack_limit_);
diff --git a/deps/v8/src/parsing/preparser.cc b/deps/v8/src/parsing/preparser.cc
index 67ee1930ac..c25ed2f8dd 100644
--- a/deps/v8/src/parsing/preparser.cc
+++ b/deps/v8/src/parsing/preparser.cc
@@ -74,10 +74,6 @@ PreParser::PreParseResult PreParser::PreParseProgram() {
scope->set_is_being_lazily_parsed(true);
#endif
- // Note: We should only skip the hashbang in non-Eval scripts
- // (currently, Eval is not handled by the PreParser).
- scanner()->SkipHashBang();
-
// ModuleDeclarationInstantiation for Source Text Module Records creates a
// new Module Environment Record whose outer lexical environment record is
// the global scope.
diff --git a/deps/v8/src/parsing/scanner-inl.h b/deps/v8/src/parsing/scanner-inl.h
index b76076d92f..53b53cb998 100644
--- a/deps/v8/src/parsing/scanner-inl.h
+++ b/deps/v8/src/parsing/scanner-inl.h
@@ -505,6 +505,10 @@ V8_INLINE Token::Value Scanner::ScanSingleToken() {
return ScanTemplateSpan();
case Token::PRIVATE_NAME:
+ if (source_pos() == 0 && Peek() == '!') {
+ token = SkipSingleLineComment();
+ continue;
+ }
return ScanPrivateName();
case Token::WHITESPACE:
diff --git a/deps/v8/src/parsing/scanner.cc b/deps/v8/src/parsing/scanner.cc
index 28e4374787..d444719f63 100644
--- a/deps/v8/src/parsing/scanner.cc
+++ b/deps/v8/src/parsing/scanner.cc
@@ -314,13 +314,6 @@ Token::Value Scanner::SkipMultiLineComment() {
return Token::ILLEGAL;
}
-void Scanner::SkipHashBang() {
- if (c0_ == '#' && Peek() == '!' && source_pos() == 0) {
- SkipSingleLineComment();
- Scan();
- }
-}
-
Token::Value Scanner::ScanHtmlComment() {
// Check for <!-- comments.
DCHECK_EQ(c0_, '!');
diff --git a/deps/v8/src/parsing/scanner.h b/deps/v8/src/parsing/scanner.h
index d9216f222a..871204bb55 100644
--- a/deps/v8/src/parsing/scanner.h
+++ b/deps/v8/src/parsing/scanner.h
@@ -421,9 +421,6 @@ class V8_EXPORT_PRIVATE Scanner {
const Utf16CharacterStream* stream() const { return source_; }
- // If the next characters in the stream are "#!", the line is skipped.
- void SkipHashBang();
-
private:
// Scoped helper for saving & restoring scanner error state.
// This is used for tagged template literals, in which normally forbidden