details: https://hg.nginx.org/njs/rev/af41742d63a2
branches:
changeset: 2120:af41742d63a2
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed May 17 00:39:56 2023 -0700
description:
Fixed implicit name for a function expression declared in arrays.
diffstat:
src/njs_generator.c | 9 ++++++---
src/test/njs_unit_test.c | 3 +++
2 files changed, 9 insertions(+), 3 deletions(-)
diffs (32 lines):
diff -r 884100020b1b -r af41742d63a2 src/njs_generator.c
--- a/src/njs_generator.c Wed May 17 00:39:45 2023 -0700
+++ b/src/njs_generator.c Wed May 17 00:39:56 2023 -0700
@@ -3235,9 +3235,12 @@ njs_generate_assignment_end(njs_vm_t *vm
switch (lvalue->token_type) {
case NJS_TOKEN_PROPERTY_INIT:
- if ((expr->token_type == NJS_TOKEN_FUNCTION
- || expr->token_type == NJS_TOKEN_FUNCTION_EXPRESSION
- || expr->token_type == NJS_TOKEN_ASYNC_FUNCTION_EXPRESSION))
+ if ((object->token_type == NJS_TOKEN_OBJECT
+ || (object->token_type == NJS_TOKEN_OBJECT_VALUE
+ && object->u.object->token_type == NJS_TOKEN_OBJECT))
+ && (expr->token_type == NJS_TOKEN_FUNCTION
+ || expr->token_type == NJS_TOKEN_FUNCTION_EXPRESSION
+ || expr->token_type == NJS_TOKEN_ASYNC_FUNCTION_EXPRESSION))
{
if (property->token_type == NJS_TOKEN_STRING) {
njs_value_assign(&expr->u.value.data.u.lambda->name,
diff -r 884100020b1b -r af41742d63a2 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Wed May 17 00:39:45 2023 -0700
+++ b/src/test/njs_unit_test.c Wed May 17 00:39:56 2023 -0700
@@ -3925,6 +3925,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("var obj = {}; ({[obj](){}}); typeof obj"),
njs_str("object") },
+ { njs_str("[function(){}][0].name"),
+ njs_str("") },
+
{ njs_str("var called = false;"
"({"
" [{toString(){ if (called) throw 'OOps'; called = true; return 'a'}}](){}"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel