diff --git a/src/compile.c b/src/compile.c index 5253e35..68eefd7 100644 --- a/src/compile.c +++ b/src/compile.c @@ -533,6 +533,18 @@ compile_complex_assignment( struct apfl_position position, struct instruction_list *ilist ) { + // TODO: This is not entirely correct: By evaluating the RHS first, it might + // affect variables used in the matcher. This is only really important when + // predicates are used, which are not yet implemented: + // + // x = {true} + // foo?x = ({x={false}}) + // + // This should succeed: The predicate x should be loaded before the + // evaluation of the rhs occurs. With our current implementation it will + // fail, though. + TRY(compile_expr(compiler, assignment->rhs, ilist)); + TRY(ilist_ensure_cap(compiler, ilist, 2)); struct matcher_instruction_list *milist; @@ -555,8 +567,6 @@ compile_complex_assignment( TRY(concat_ilists(compiler, ilist, ilists.newvars)); - TRY(compile_expr(compiler, assignment->rhs, ilist)); - TRY(ilist_ensure_cap(compiler, ilist, 1)); ilist_put_insn(ilist, INSN_MATCHER_MUST_MATCH);