From: kozyatinskiy Date: Thu, 30 Apr 2015 12:44:52 +0000 (-0700) Subject: [V8] Use previous token location as EOS token location X-Git-Tag: upstream/4.7.83~2876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81afc9313ce84350bcba9f84b255a77e97cd3726;p=platform%2Fupstream%2Fv8.git [V8] Use previous token location as EOS token location EOS token location is useless for users and messages.js are not ready for its location. With this CL we use location of token before EOS for it. LOG=Y BUG=chromium:480652 R=yurys@chromium.org,yangguo@chromium.org Review URL: https://codereview.chromium.org/1100993003 Cr-Commit-Position: refs/heads/master@{#28164} --- diff --git a/src/scanner.cc b/src/scanner.cc index 1dae1e4..6187c66 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -225,6 +225,10 @@ static const byte one_char_tokens[] = { Token::Value Scanner::Next() { + if (next_.token == Token::EOS) { + next_.location.beg_pos = current_.location.beg_pos; + next_.location.end_pos = current_.location.end_pos; + } current_ = next_; has_line_terminator_before_next_ = false; has_multiline_comment_before_next_ = false; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index f544288..64583e6 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -12565,6 +12565,18 @@ THREADED_TEST(TryCatchSourceInfo) { } +THREADED_TEST(TryCatchSourceInfoForEOSError) { + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + v8::TryCatch try_catch; + v8::Script::Compile(v8_str("!\n")); + CHECK(try_catch.HasCaught()); + v8::Handle message = try_catch.Message(); + CHECK_EQ(1, message->GetLineNumber()); + CHECK_EQ(0, message->GetStartColumn()); +} + + THREADED_TEST(CompilationCache) { LocalContext context; v8::HandleScope scope(context->GetIsolate());