Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index a344b28e0a030bcfc2410849ad8fa5a65b26153e..39310123e48440d33e0f59bcd576aec2270cbdea 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -1780,6 +1780,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { |
ASSERT(args.length() == 5); |
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
CONVERT_ARG_CHECKED(String, source, 1); |
+ // If source is the empty string we set it to "(?:)" instead as |
+ // suggested by ECMA-262, 5th, section 15.10.4.1. |
+ if (source->length() == 0) source = isolate->heap()->query_colon_symbol(); |
Object* global = args[2]; |
if (!global->IsTrue()) global = isolate->heap()->false_value(); |