Skip to content
Myr

Fix a tripped assertion when generating reduces

Before adoption: this commit came in with the history the project adopted, so no landing records it.

A noop body, while useless, should still compile successfully

authored by William Langford · committed by Nicolas Williams · parent 3a8c8f4 · Browse files · 2 files+11 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−1 removed

  • tests:+5 added−0 removed
  • other:+6 added−1 removed

2 files+11 added−1 removed

modified:src/compile.c+6 added-1 removed
822 unmodified lines
823824block gen_reduce(block source, block matcher, block init, block body) {825 block res_var = gen_op_var_fresh(STOREV, "reduce");826 block update_var = gen_op_bound(STOREV, res_var);827 block jmp = gen_op_target(JUMP, body);827 block jmp = gen_op_targetlater(JUMP);828 if (body.last == NULL) {829 inst_set_target(jmp, jmp);830 } else {831 inst_set_target(jmp, body);832 }833 block loop = BLOCK(gen_op_simple(DUPN),834 source,835 bind_alternation_matchers(matcher,836 BLOCK(gen_op_bound(LOADVN, res_var),
576 unmodified lines
modified:tests/jq.test+5 added
708 unmodified lines
709reduce range(5) as $n ([]; select($n%2 == 1) | . + [$n])710null711[1,3]712713# This, while useless, should still compile.714reduce . as $n (.; .)715null716null717718. as $dot|any($dot[];not)719[1,2,3,4,true,false,1,2,3,4,5]720true721
674 unmodified lines