Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Unified Diff: src/js/regexp.js

Issue 1679123007: [regexp] implement RegExp.prototype.toString for non-RegExp receiver. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/regexp-tostring.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/regexp.js
diff --git a/src/js/regexp.js b/src/js/regexp.js
index a456952ef37ba6ee5797f546256f904e551ec900..f4c6f8a6cee8c09c00e2551be127ae42677e0567 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -278,8 +278,11 @@ function RegExpToString() {
%IncrementUseCounter(kRegExpPrototypeToString);
return '/(?:)/';
}
- throw MakeTypeError(kIncompatibleMethodReceiver,
- 'RegExp.prototype.toString', this);
+ if (!IS_RECEIVER(this)) {
+ throw MakeTypeError(
+ kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
+ }
+ return '/' + TO_STRING(this.pattern()) + '/' + TO_STRING(this.flags());
}
var result = '/' + REGEXP_SOURCE(this) + '/';
if (REGEXP_GLOBAL(this)) result += 'g';
« no previous file with comments | « no previous file | test/mjsunit/es6/regexp-tostring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698