fixed regression in error message display introduced in commit 42eb279

This commit is contained in:
Fabrice Bellard
2025-10-12 13:23:50 +02:00
parent eb9fa2b8da
commit 63450099a3
3 changed files with 32 additions and 26 deletions

View File

@@ -256,6 +256,7 @@ DEF(SyntaxError, "SyntaxError")
DEF(TypeError, "TypeError") DEF(TypeError, "TypeError")
DEF(URIError, "URIError") DEF(URIError, "URIError")
DEF(InternalError, "InternalError") DEF(InternalError, "InternalError")
DEF(AggregateError, "AggregateError")
/* private symbols */ /* private symbols */
DEF(Private_brand, "<brand>") DEF(Private_brand, "<brand>")
/* symbols */ /* symbols */

View File

@@ -38475,7 +38475,7 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
case JS_DEF_PROP_UNDEFINED: case JS_DEF_PROP_UNDEFINED:
val = JS_UNDEFINED; val = JS_UNDEFINED;
break; break;
case JS_DEF_PROP_SYMBOL: case JS_DEF_PROP_ATOM:
val = JS_AtomToValue(ctx, e->u.i32); val = JS_AtomToValue(ctx, e->u.i32);
break; break;
case JS_DEF_PROP_BOOL: case JS_DEF_PROP_BOOL:
@@ -40328,19 +40328,21 @@ static const JSCFunctionListEntry js_error_proto_funcs[] = {
}; };
/* 2 entries for each native error class */ /* 2 entries for each native error class */
/* Note: we use an atom to avoid the autoinit definition which does
not work in get_prop_string() */
static const JSCFunctionListEntry js_native_error_proto_funcs[] = { static const JSCFunctionListEntry js_native_error_proto_funcs[] = {
#define DEF(name) \ #define DEF(name) \
JS_PROP_STRING_DEF("name", name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),\ JS_PROP_ATOM_DEF("name", name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),\
JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ), JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
DEF("EvalError") DEF(JS_ATOM_EvalError)
DEF("RangeError") DEF(JS_ATOM_RangeError)
DEF("ReferenceError") DEF(JS_ATOM_ReferenceError)
DEF("SyntaxError") DEF(JS_ATOM_SyntaxError)
DEF("TypeError") DEF(JS_ATOM_TypeError)
DEF("URIError") DEF(JS_ATOM_URIError)
DEF("InternalError") DEF(JS_ATOM_InternalError)
DEF("AggregateError") DEF(JS_ATOM_AggregateError)
#undef DEF #undef DEF
}; };
@@ -49700,19 +49702,19 @@ static JSValue js_symbol_keyFor(JSContext *ctx, JSValueConst this_val,
static const JSCFunctionListEntry js_symbol_funcs[] = { static const JSCFunctionListEntry js_symbol_funcs[] = {
JS_CFUNC_DEF("for", 1, js_symbol_for ), JS_CFUNC_DEF("for", 1, js_symbol_for ),
JS_CFUNC_DEF("keyFor", 1, js_symbol_keyFor ), JS_CFUNC_DEF("keyFor", 1, js_symbol_keyFor ),
JS_PROP_SYMBOL_DEF("toPrimitive", JS_ATOM_Symbol_toPrimitive, 0), JS_PROP_ATOM_DEF("toPrimitive", JS_ATOM_Symbol_toPrimitive, 0),
JS_PROP_SYMBOL_DEF("iterator", JS_ATOM_Symbol_iterator, 0), JS_PROP_ATOM_DEF("iterator", JS_ATOM_Symbol_iterator, 0),
JS_PROP_SYMBOL_DEF("match", JS_ATOM_Symbol_match, 0), JS_PROP_ATOM_DEF("match", JS_ATOM_Symbol_match, 0),
JS_PROP_SYMBOL_DEF("matchAll", JS_ATOM_Symbol_matchAll, 0), JS_PROP_ATOM_DEF("matchAll", JS_ATOM_Symbol_matchAll, 0),
JS_PROP_SYMBOL_DEF("replace", JS_ATOM_Symbol_replace, 0), JS_PROP_ATOM_DEF("replace", JS_ATOM_Symbol_replace, 0),
JS_PROP_SYMBOL_DEF("search", JS_ATOM_Symbol_search, 0), JS_PROP_ATOM_DEF("search", JS_ATOM_Symbol_search, 0),
JS_PROP_SYMBOL_DEF("split", JS_ATOM_Symbol_split, 0), JS_PROP_ATOM_DEF("split", JS_ATOM_Symbol_split, 0),
JS_PROP_SYMBOL_DEF("toStringTag", JS_ATOM_Symbol_toStringTag, 0), JS_PROP_ATOM_DEF("toStringTag", JS_ATOM_Symbol_toStringTag, 0),
JS_PROP_SYMBOL_DEF("isConcatSpreadable", JS_ATOM_Symbol_isConcatSpreadable, 0), JS_PROP_ATOM_DEF("isConcatSpreadable", JS_ATOM_Symbol_isConcatSpreadable, 0),
JS_PROP_SYMBOL_DEF("hasInstance", JS_ATOM_Symbol_hasInstance, 0), JS_PROP_ATOM_DEF("hasInstance", JS_ATOM_Symbol_hasInstance, 0),
JS_PROP_SYMBOL_DEF("species", JS_ATOM_Symbol_species, 0), JS_PROP_ATOM_DEF("species", JS_ATOM_Symbol_species, 0),
JS_PROP_SYMBOL_DEF("unscopables", JS_ATOM_Symbol_unscopables, 0), JS_PROP_ATOM_DEF("unscopables", JS_ATOM_Symbol_unscopables, 0),
JS_PROP_SYMBOL_DEF("asyncIterator", JS_ATOM_Symbol_asyncIterator, 0), JS_PROP_ATOM_DEF("asyncIterator", JS_ATOM_Symbol_asyncIterator, 0),
}; };
/* Set/Map/WeakSet/WeakMap */ /* Set/Map/WeakSet/WeakMap */
@@ -54447,9 +54449,12 @@ static int JS_AddIntrinsicBasicObjects(JSContext *ctx)
JSValue func_obj; JSValue func_obj;
const JSCFunctionListEntry *funcs; const JSCFunctionListEntry *funcs;
int n_args; int n_args;
char buf[ATOM_GET_STR_BUF_SIZE];
const char *name = JS_AtomGetStr(ctx, buf, sizeof(buf),
JS_ATOM_EvalError + i);
n_args = 1 + (i == JS_AGGREGATE_ERROR); n_args = 1 + (i == JS_AGGREGATE_ERROR);
funcs = js_native_error_proto_funcs + 2 * i; funcs = js_native_error_proto_funcs + 2 * i;
func_obj = JS_NewCConstructor(ctx, -1, funcs[0].u.str, func_obj = JS_NewCConstructor(ctx, -1, name,
ft.generic, n_args, JS_CFUNC_constructor_or_func_magic, i, ft.generic, n_args, JS_CFUNC_constructor_or_func_magic, i,
obj, obj,
NULL, 0, NULL, 0,

View File

@@ -1097,7 +1097,7 @@ typedef struct JSCFunctionListEntry {
#define JS_DEF_PROP_UNDEFINED 7 #define JS_DEF_PROP_UNDEFINED 7
#define JS_DEF_OBJECT 8 #define JS_DEF_OBJECT 8
#define JS_DEF_ALIAS 9 #define JS_DEF_ALIAS 9
#define JS_DEF_PROP_SYMBOL 10 #define JS_DEF_PROP_ATOM 10
#define JS_DEF_PROP_BOOL 11 #define JS_DEF_PROP_BOOL 11
/* Note: c++ does not like nested designators */ /* Note: c++ does not like nested designators */
@@ -1112,7 +1112,7 @@ typedef struct JSCFunctionListEntry {
#define JS_PROP_INT64_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT64, 0, .u = { .i64 = val } } #define JS_PROP_INT64_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT64, 0, .u = { .i64 = val } }
#define JS_PROP_DOUBLE_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_DOUBLE, 0, .u = { .f64 = val } } #define JS_PROP_DOUBLE_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_DOUBLE, 0, .u = { .f64 = val } }
#define JS_PROP_UNDEFINED_DEF(name, prop_flags) { name, prop_flags, JS_DEF_PROP_UNDEFINED, 0, .u = { .i32 = 0 } } #define JS_PROP_UNDEFINED_DEF(name, prop_flags) { name, prop_flags, JS_DEF_PROP_UNDEFINED, 0, .u = { .i32 = 0 } }
#define JS_PROP_SYMBOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_SYMBOL, 0, .u = { .i32 = val } } #define JS_PROP_ATOM_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_ATOM, 0, .u = { .i32 = val } }
#define JS_PROP_BOOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_BOOL, 0, .u = { .i32 = val } } #define JS_PROP_BOOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_BOOL, 0, .u = { .i32 = val } }
#define JS_OBJECT_DEF(name, tab, len, prop_flags) { name, prop_flags, JS_DEF_OBJECT, 0, .u = { .prop_list = { tab, len } } } #define JS_OBJECT_DEF(name, tab, len, prop_flags) { name, prop_flags, JS_DEF_OBJECT, 0, .u = { .prop_list = { tab, len } } }
#define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, -1 } } } #define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, -1 } } }