globals: Fix math operations returning argument list on single arg

This commit is contained in:
Laria 2022-10-30 23:08:41 +01:00
parent 39578c9478
commit 154cc42740
3 changed files with 19 additions and 1 deletions

View file

@ -59,6 +59,7 @@ functionaltest("function-mutable-capture")
functionaltest("map")
functionaltest("deconstruct")
functionaltest("shadowing")
functionaltest("mathops")
install(TARGETS apfl DESTINATION lib)
install(TARGETS apfl-bin DESTINATION bin)

View file

@ -0,0 +1,17 @@
===== script =====
print (+ 1 2)
print (+ 1 2 3 4)
print (- 1)
print (- 1 2)
print (- 1 2 3)
print (* 1 2 3)
print (/ 1 2 4)
===== output =====
3
10
-1
-1
-4
6
0.125

View file

@ -101,7 +101,7 @@ impl_eq(apfl_ctx ctx)
apfl_get_list_member_by_index(ctx, 0, 0); \
apfl_number num = apfl_get_number(ctx, -1); \
if (len == 1) { \
single(num); \
apfl_push_number(ctx, single(num)); \
return; \
} \
\