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.
}
block gen_cond(block cond, block iftrue, block iffalse) {
- return BLOCK(gen_op_simple(DUP), cond,
+ return BLOCK(gen_op_simple(DUP), BLOCK(gen_subexp(cond), gen_op_simple(POP)),
gen_condbranch(BLOCK(gen_op_simple(POP), iftrue),
BLOCK(gen_op_simple(POP), iffalse)));
}
{"a":null,"b":null}
{"a":null,"b":"b"}
+# Regression test for #1368
+(.. | select(type == "object" and has("b") and (.b | type) == "array")|.b) |= .[0]
+{"a": {"b": [1, {"b": 3}]}}
+{"a": {"b": 1}}
+