Matchers: Don't return twice when value to capture is missing

We called return_from_matcher once inside
matcher_evaluate_capturing_instruction and outside of it. That way we
returned not to the parent call stack entry but to the grandparent.
This commit is contained in:
Laria 2022-11-19 23:14:09 +01:00
parent 20c2880f4c
commit 3d7bef187c
3 changed files with 19 additions and 1 deletions

View file

@ -67,6 +67,7 @@ functionaltest("while")
functionaltest("eq")
functionaltest("chained-assignments")
functionaltest("dictionary-assignments")
functionaltest("variadic-functions")
install(TARGETS apfl DESTINATION lib)
install(TARGETS apfl-bin DESTINATION bin)

View file

@ -1159,7 +1159,6 @@ matcher_evaluate_capturing_instruction(
struct apfl_value cur;
if (!matcher_current_val(ctx, cse, &cur)) {
return_from_matcher(ctx, false);
return false;
}

View file

@ -0,0 +1,18 @@
===== script =====
foo = {
x y z -> 3
x y -> 2
x -> 1
-> 0
}
print (foo 1 1 1)
print (foo 1 1)
print (foo 1)
print (foo)
===== output =====
3
2
1
0