From 647c6a7927c5c6ef2941ba1dc3c1d40c2c7d7f34 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 12 Mar 2021 13:04:50 +0100 Subject: compiler: fix parsing of arrow functions with single expression body Ensure that an arrow function body expression is parsed with P_ASSIGN precedence to not greedily consume comma expressions. This ensures that an expression like () => 1, 2 is parsed as function [() => 1], integer [2] and not as function [() => 1, 2]. Signed-off-by: Jo-Philipp Wich --- compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler.c') diff --git a/compiler.c b/compiler.c index 5c31409..15c8f8e 100644 --- a/compiler.c +++ b/compiler.c @@ -1118,7 +1118,7 @@ uc_compiler_compile_arrowfn(uc_compiler *compiler, json_object *args, bool resta } } else { - uc_compiler_compile_expression(&fncompiler); + uc_compiler_parse_precedence(&fncompiler, P_ASSIGN); uc_compiler_emit_insn(&fncompiler, 0, I_RETURN); } -- cgit v1.2.3