Welcome! Log In Create A New Profile

Advanced

[njs] Function declaration should return "undefined".

April 04, 2017 06:26AM
details: http://hg.nginx.org/njs/rev/ada17c8bdd5a
branches:
changeset: 332:ada17c8bdd5a
user: Igor Sysoev <igor@sysoev.ru>
date: Tue Apr 04 10:47:12 2017 +0300
description:
Function declaration should return "undefined".

diffstat:

njs/njs_generator.c | 7 ++++---
njs/test/njs_unit_test.c | 6 ++++++
2 files changed, 10 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 26e0ebd97454 -r ada17c8bdd5a njs/njs_generator.c
--- a/njs/njs_generator.c Tue Apr 04 06:16:49 2017 +0300
+++ b/njs/njs_generator.c Tue Apr 04 10:47:12 2017 +0300
@@ -1261,9 +1261,10 @@ njs_generate_stop_statement(njs_vm_t *vm
stop->code.retval = NJS_VMCODE_NO_RETVAL;

index = NJS_INDEX_NONE;
-
- if (node->right != NULL) {
- index = node->right->index;
+ node = node->right;
+
+ if (node != NULL && node->token != NJS_TOKEN_FUNCTION) {
+ index = node->index;
}

if (index == NJS_INDEX_NONE) {
diff -r 26e0ebd97454 -r ada17c8bdd5a njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Apr 04 06:16:49 2017 +0300
+++ b/njs/test/njs_unit_test.c Tue Apr 04 10:47:12 2017 +0300
@@ -4199,6 +4199,12 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("function () { } f()"),
nxt_string("SyntaxError: Unexpected token \"(\" in 1") },

+ { nxt_string("function f() { }"),
+ nxt_string("undefined") },
+
+ { nxt_string("var x; function f() { }"),
+ nxt_string("undefined") },
+
{ nxt_string("function f() { } f()"),
nxt_string("undefined") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Function declaration should return "undefined".

Igor Sysoev 802 April 04, 2017 06:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 119
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready