[turbofan] Fix exception message for non-constructables.
This fixes the message reported via the {TypeError} thrown when trying to call a non-constructable function as a constructor. Also adds some more related message tests for similar exceptions. R=bmeurer@chromium.org TEST=message/call-non-constructable BUG=chromium:661579 Review-Url: https://codereview.chromium.org/2523803003 Cr-Commit-Position: refs/heads/master@{#41220}
This commit is contained in:
parent
a127fffc1b
commit
2b96c9d7c0
@ -412,7 +412,8 @@ Reduction JSCallReducer::ReduceJSCallConstruct(Node* node) {
|
||||
if (!function->IsConstructor()) {
|
||||
NodeProperties::ReplaceValueInputs(node, target);
|
||||
NodeProperties::ChangeOp(
|
||||
node, javascript()->CallRuntime(Runtime::kThrowCalledNonCallable));
|
||||
node, javascript()->CallRuntime(
|
||||
Runtime::kThrowConstructedNonConstructable));
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
|
8
test/message/call-non-constructable.js
Normal file
8
test/message/call-non-constructable.js
Normal file
@ -0,0 +1,8 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
// Note that {unescape} is an example of a non-constructable function. If that
|
||||
// ever changes and this test needs to be adapted, make sure to choose another
|
||||
// non-constructable {JSFunction} object instead.
|
||||
new unescape();
|
9
test/message/call-non-constructable.out
Normal file
9
test/message/call-non-constructable.out
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2016 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:8: TypeError: unescape is not a constructor
|
||||
new unescape();
|
||||
^
|
||||
TypeError: unescape is not a constructor
|
||||
at *%(basename)s:8:1
|
6
test/message/call-primitive-constructor.js
Normal file
6
test/message/call-primitive-constructor.js
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
var non_callable = 0;
|
||||
new non_callable();
|
9
test/message/call-primitive-constructor.out
Normal file
9
test/message/call-primitive-constructor.out
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2016 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:6: TypeError: non_callable is not a constructor
|
||||
new non_callable();
|
||||
^
|
||||
TypeError: non_callable is not a constructor
|
||||
at *%(basename)s:6:1
|
6
test/message/call-primitive-function.js
Normal file
6
test/message/call-primitive-function.js
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
var non_callable = 0;
|
||||
non_callable();
|
9
test/message/call-primitive-function.out
Normal file
9
test/message/call-primitive-function.out
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2016 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:6: TypeError: non_callable is not a function
|
||||
non_callable();
|
||||
^
|
||||
TypeError: non_callable is not a function
|
||||
at *%(basename)s:6:1
|
5
test/message/call-undeclared-function.js
Normal file
5
test/message/call-undeclared-function.js
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright 2016 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.
|
||||
|
||||
not_declared();
|
9
test/message/call-undeclared-function.out
Normal file
9
test/message/call-undeclared-function.out
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2016 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: ReferenceError: not_declared is not defined
|
||||
not_declared();
|
||||
^
|
||||
ReferenceError: not_declared is not defined
|
||||
at *%(basename)s:5:1
|
Loading…
Reference in New Issue
Block a user