Handle<Object> receiver =
Utils::OpenHandle(*v8::Local<v8::Value>(info.This()));
Handle<JSRegExp> regexp = Handle<JSRegExp>::cast(receiver);
- Handle<String> pattern(regexp->Pattern(), isolate);
- MaybeHandle<String> maybe = EscapeRegExpSource(isolate, pattern);
-
Handle<String> result;
- if (!maybe.ToHandle(&result)) {
- isolate->OptionalRescheduleException(false);
- return;
+ if (regexp->TypeTag() == JSRegExp::NOT_COMPILED) {
+ result = isolate->factory()->empty_string();
+ } else {
+ Handle<String> pattern(regexp->Pattern(), isolate);
+ MaybeHandle<String> maybe = EscapeRegExpSource(isolate, pattern);
+ if (!maybe.ToHandle(&result)) {
+ isolate->OptionalRescheduleException(false);
+ return;
+ }
}
info.GetReturnValue().Set(Utils::ToLocal(result));
}
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+Error.prepareStackTrace = function (a,b) { return b; };
+
+try {
+ /(invalid regexp/;
+} catch (e) {
+ e.stack[0].getThis().toString();
+}