[njs] Function declaration should return "undefined".
Igor Sysoev
igor at sysoev.ru
Tue Apr 4 10:24:38 UTC 2017
details: http://hg.nginx.org/njs/rev/ada17c8bdd5a
branches:
changeset: 332:ada17c8bdd5a
user: Igor Sysoev <igor at 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") },
More information about the nginx-devel
mailing list