diff --git a/src/js/regexp.js b/src/js/regexp.js index f4c6f8a6ce..9f2a1688c8 100644 --- a/src/js/regexp.js +++ b/src/js/regexp.js @@ -282,7 +282,7 @@ function RegExpToString() { throw MakeTypeError( kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this); } - return '/' + TO_STRING(this.pattern()) + '/' + TO_STRING(this.flags()); + return '/' + TO_STRING(this.source) + '/' + TO_STRING(this.flags); } var result = '/' + REGEXP_SOURCE(this) + '/'; if (REGEXP_GLOBAL(this)) result += 'g'; diff --git a/test/mjsunit/es6/regexp-tostring.js b/test/mjsunit/es6/regexp-tostring.js index 8e6857ee89..3deeeb7ed8 100644 --- a/test/mjsunit/es6/regexp-tostring.js +++ b/test/mjsunit/es6/regexp-tostring.js @@ -6,7 +6,7 @@ var log = []; var fake = { - pattern: function() { + get source() { log.push("p"); return { toString: function() { @@ -15,7 +15,7 @@ var fake = } }; }, - flags: function() { + get flags() { log.push("f"); return { toString: function() { @@ -38,8 +38,8 @@ function testThrows(x) { testThrows(1); testThrows(null); -Number.prototype.pattern = () => "a"; -Number.prototype.flags = () => "b"; +Number.prototype.source = "a"; +Number.prototype.flags = "b"; testThrows(1); assertEquals("/pattern/flags", RegExp.prototype.toString.call(fake)); diff --git a/test/mjsunit/regexp.js b/test/mjsunit/regexp.js index b6f019ea26..1a5de2addf 100644 --- a/test/mjsunit/regexp.js +++ b/test/mjsunit/regexp.js @@ -719,9 +719,6 @@ assertThrows("RegExp.prototype.toString.call(0)", TypeError); assertThrows("RegExp.prototype.toString.call('')", TypeError); assertThrows("RegExp.prototype.toString.call(false)", TypeError); assertThrows("RegExp.prototype.toString.call(true)", TypeError); -assertThrows("RegExp.prototype.toString.call([])", TypeError); -assertThrows("RegExp.prototype.toString.call({})", TypeError); -assertThrows("RegExp.prototype.toString.call(function(){})", TypeError); // Test mutually recursive capture and backreferences. assertEquals(["b", "", ""], /(\2)b(\1)/.exec("aba"));