Commit 5aacb931 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Correctly report octal literals in strict mode when preparsing.

SingletonLogger::LogMessage did not work as advertised and
overwrote existing message.

R=mstarzinger@chromium.org
BUG=v8:2220
TEST=test-parsing/PreparserStrictOctal

Review URL: https://chromiumcodereview.appspot.com/10689134

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12031 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 09bfdabd
......@@ -4362,6 +4362,7 @@ class SingletonLogger : public ParserRecorder {
int end,
const char* message,
const char* argument_opt) {
if (has_error_) return;
has_error_ = true;
start_ = start;
end_ = end;
......
......@@ -1236,3 +1236,26 @@ TEST(ParserSync) {
}
}
}
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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment