Skip to content

Commit 7558624

Browse files
authored
Fix error instance query if the error is from a Proxy (#4459)
When accessing an error's type there is no need to check the Proxy prototype (as there is none). Fixes: #4440 JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent 3dc6ed0 commit 7558624

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

jerry-core/ecma/operations/ecma-exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ
170170
ecma_standard_error_t
171171
ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */
172172
{
173-
if (error_object->u2.prototype_cp == JMEM_CP_NULL)
173+
if (error_object->u2.prototype_cp == JMEM_CP_NULL || ECMA_OBJECT_IS_PROXY (error_object))
174174
{
175175
return ECMA_ERROR_NONE;
176176
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var handler = {
16+
get: function(target, key) {
17+
assert(typeof(target) === 'function');
18+
assert(key === 'dummy');
19+
return 42;
20+
}
21+
};
22+
23+
try {
24+
throw new Proxy(Function(), handler);
25+
assert(false);
26+
} catch (ex) {
27+
/* 'ex' is the Proxy */
28+
assert(typeof(ex) === 'function');
29+
assert(ex.dummy === 42);
30+
}
31+
32+
try {
33+
throw new Proxy(EvalError(), { });
34+
} catch (ex) {
35+
assert(ex instanceof EvalError);
36+
}

0 commit comments

Comments
 (0)