Revision: 12031
Author: [email protected]
Date: Tue Jul 10 05:24:17 2012
Log: Correctly report octal literals in strict mode when preparsing.
SingletonLogger::LogMessage did not work as advertised and
overwrote existing message.
[email protected]
BUG=v8:2220
TEST=test-parsing/PreparserStrictOctal
Review URL: https://chromiumcodereview.appspot.com/10689134
http://code.google.com/p/v8/source/detail?r=12031
Modified:
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/test/cctest/test-parsing.cc
=======================================
--- /branches/bleeding_edge/src/parser.cc Mon Jul 9 01:59:03 2012
+++ /branches/bleeding_edge/src/parser.cc Tue Jul 10 05:24:17 2012
@@ -4362,6 +4362,7 @@
int end,
const char* message,
const char* argument_opt) {
+ if (has_error_) return;
has_error_ = true;
start_ = start;
end_ = end;
=======================================
--- /branches/bleeding_edge/test/cctest/test-parsing.cc Wed Jun 20 03:56:53
2012
+++ /branches/bleeding_edge/test/cctest/test-parsing.cc Tue Jul 10 05:24:17
2012
@@ -1236,3 +1236,26 @@
}
}
}
+
+
+TEST(PreparserStrictOctal) {
+ // Test that syntax error caused by octal literal is reported correctly
as
+ // such (issue 2220).
+ v8::internal::FLAG_min_preparse_length = 1; // Force preparsing.
+ v8::V8::Initialize();
+ v8::HandleScope scope;
+ v8::Context::Scope context_scope(v8::Context::New());
+ v8::TryCatch try_catch;
+ const char* script =
+ "\"use strict\"; \n"
+ "a = function() { \n"
+ " b = function() { \n"
+ " 01; \n"
+ " }; \n"
+ "}; \n";
+ v8::Script::Compile(v8::String::New(script));
+ CHECK(try_catch.HasCaught());
+ v8::String::Utf8Value exception(try_catch.Exception());
+ CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
+ *exception);
+}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev