[string] Fix error message in String.prototype.repeat.

R=yangguo@chromium.org
TEST=message/regress/regress-crbug-691194
BUG=chromium:691194

Change-Id: I72198e087f88abf89cdd38b99c19e10cbebda08d
Reviewed-on: https://chromium-review.googlesource.com/445942
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43480}
This commit is contained in:
Michael Starzinger 2017-02-27 14:43:32 +01:00 committed by Commit Bot
parent 09a07038f2
commit 08d84f6d23
3 changed files with 16 additions and 1 deletions

View File

@ -220,7 +220,7 @@ function StringRepeat(count) {
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n > %_MaxSmi()) throw %make_range_error(kInvalidCountValue);
if (n > %_MaxSmi()) throw %make_range_error(kInvalidStringLength);
var r = "";
while (true) {

View File

@ -0,0 +1,5 @@
// Copyright 2017 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.
"foo".repeat(1 << 30)

View File

@ -0,0 +1,10 @@
# Copyright 2017 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.
*%(basename)s:5: RangeError: Invalid string length
"foo".repeat(1 << 30)
^
RangeError: Invalid string length
at String.repeat (native)
at *%(basename)s:5:7