Reviewers: Yang, yurys,
Message:
Yury, please take a look!
Description:
[V8] Fix line number for eos error
BUG=480652
[email protected],[email protected]
Please review this at https://codereview.chromium.org/1100993003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -1 lines):
M src/messages.js
M test/cctest/test-api.cc
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index
e997061fc47416b04992090cef81a6fd8d7d7452..034237466ee3b05d6dd6351475488eb88235f6e5
100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -401,10 +401,15 @@ function ScriptLineFromPosition(position) {
var line_ends = this.line_ends;
// We'll never find invalid positions so bail right away.
- if (position > line_ends[upper]) {
+ if (position - 1 > line_ends[upper]) {
return -1;
}
+ // Process EOS token
+ if (position > line_ends[upper]) {
+ return upper;
+ }
+
// This means we don't have to safe-guard indexing line_ends[i - 1].
if (position <= line_ends[0]) {
return 0;
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
4ef83c71ed5983b03365f69bb564fe6c6fecc54b..9cb372c722df0d1ddff857e4c176c53dcc34c13c
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -12553,6 +12553,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<v8::Message> message = try_catch.Message();
+ CHECK_EQ(1, message->GetLineNumber());
+ CHECK_EQ(2, message->GetStartColumn());
+}
+
+
THREADED_TEST(CompilationCache) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.