summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compiler.c2
-rw-r--r--tests/03_bugs/08_compiler_arrow_fn_expressions15
2 files changed, 16 insertions, 1 deletions
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);
}
diff --git a/tests/03_bugs/08_compiler_arrow_fn_expressions b/tests/03_bugs/08_compiler_arrow_fn_expressions
new file mode 100644
index 0000000..5cd8960
--- /dev/null
+++ b/tests/03_bugs/08_compiler_arrow_fn_expressions
@@ -0,0 +1,15 @@
+Arrow functions with single expression bodies were parsed with a wrong
+precedence level, causing comma expressions to be greedily consumed.
+
+-- Testcase --
+{%
+ print({
+ a: () => 1,
+ b: () => 2
+ }, "\n");
+%}
+-- End --
+
+-- Expect stdout --
+{ "a": "() => { ... }", "b": "() => { ... }" }
+-- End --