Skip to content
Myr

Conditional exprs are not path exprs (fix #1368)

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

The conditional expression in if-then-elif-else-end cannot contribute to path expressions because it doesn't change the input to any of the then/ elif/else expressions. These must be generated via gen_subexp(). See also #1366.

authored by Nicolas Williams · committed by Nicolas Williams · parent 674e9fb · Browse files · 2 files+6 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+6 added−1 removed

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

2 files+6 added−1 removed

modified:src/compile.c+1 added-1 removed
903 unmodified lines
904 body, OP_HAS_VARIABLE | OP_BIND_WILDCARD));905}906907block gen_cond(block cond, block iftrue, block iffalse) {908 return BLOCK(gen_op_simple(DUP), cond,908 return BLOCK(gen_op_simple(DUP), BLOCK(gen_subexp(cond), gen_op_simple(POP)),909 gen_condbranch(BLOCK(gen_op_simple(POP), iftrue),910 BLOCK(gen_op_simple(POP), iffalse)));911}912
366 unmodified lines
modified:tests/jq.test+5 added
1380 unmodified lines
1381(.a as $x | .b) = "b"1382{"a":null,"b":null}1383{"a":null,"b":"b"}13841385# Regression test for #13681386(.. | select(type == "object" and has("b") and (.b | type) == "array")|.b) |= .[0]1387{"a": {"b": [1, {"b": 3}]}}1388{"a": {"b": 1}}13891390