Welcome! Log In Create A New Profile

Advanced

[njs] Fixed parsing of export default declarations.

Dmitry Volyntsev
June 29, 2021 08:14AM
details: https://hg.nginx.org/njs/rev/f1a1b9ad198d
branches:
changeset: 1668:f1a1b9ad198d
user: Artem S. Povalyukhin <artem.povaluhin@gmail.com>
date: Thu Jun 24 08:53:12 2021 +0300
description:
Fixed parsing of export default declarations.

With non-assignment expression.

diffstat:

src/njs_parser.c | 6 +++++-
test/module/export_non_assignment.js | 1 +
test/njs_expect_test.exp | 2 ++
3 files changed, 8 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r f10d5c38f098 -r f1a1b9ad198d src/njs_parser.c
--- a/src/njs_parser.c Fri Jun 25 17:00:12 2021 +0000
+++ b/src/njs_parser.c Thu Jun 24 08:53:12 2021 +0300
@@ -7468,7 +7468,7 @@ njs_parser_export(njs_parser_t *parser,
node->token_line = parser->line;
parser->node = node;

- njs_parser_next(parser, njs_parser_expression);
+ njs_parser_next(parser, njs_parser_assignment_expression);

return njs_parser_after(parser, current, node, 1, njs_parser_export_after);
}
@@ -7478,6 +7478,10 @@ static njs_int_t
njs_parser_export_after(njs_parser_t *parser, njs_lexer_token_t *token,
njs_queue_link_t *current)
{
+ if (njs_parser_expect_semicolon(parser, token) != NJS_OK) {
+ return njs_parser_failed(parser);
+ }
+
parser->target->right = parser->node;
parser->node = parser->target;

diff -r f10d5c38f098 -r f1a1b9ad198d test/module/export_non_assignment.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/module/export_non_assignment.js Thu Jun 24 08:53:12 2021 +0300
@@ -0,0 +1,1 @@
+export default 10, 11;
diff -r f10d5c38f098 -r f1a1b9ad198d test/njs_expect_test.exp
--- a/test/njs_expect_test.exp Fri Jun 25 17:00:12 2021 +0000
+++ b/test/njs_expect_test.exp Thu Jun 24 08:53:12 2021 +0300
@@ -749,6 +749,8 @@ njs_test {
"Identifier \"default\" has already been declared in export.js:5\r\n"}
{"import m from 'export_non_default.js'\r\n"
"Non-default export is not supported in export_non_default.js:3\r\n"}
+ {"import m from 'export_non_assignment.js'\r\n"
+ "Unexpected token \",\" in export_non_assignment.js:1\r\n"}
{"import ref from 'ref_exception.js'\r\n"
"ReferenceError: \"undeclared\" is not defined"}
{"var ref\r\n"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed parsing of export default declarations.

Dmitry Volyntsev 152 June 29, 2021 08:14AM



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

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready