diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index 92fba2ef..a9cc3208 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -149,12 +149,12 @@ e_oplist_concat_in_place(E_OpList *dst, E_OpList *to_push) { if(to_push->first && dst->first) { - to_push->last->next = dst->first; - to_push->last = dst->last; - to_push->op_count += to_push->op_count; - to_push->encoded_size += to_push->encoded_size; + dst->last->next = to_push->first; + dst->last = to_push->last; + dst->op_count += to_push->op_count; + dst->encoded_size += to_push->encoded_size; } - else if(dst->first) + else if(!dst->first) { MemoryCopyStruct(dst, to_push); } diff --git a/src/eval/eval_parse.c b/src/eval/eval_parse.c index 7db44c92..627954a0 100644 --- a/src/eval/eval_parse.c +++ b/src/eval/eval_parse.c @@ -1800,6 +1800,8 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to { if(token.kind == E_TokenKind_Symbol && str8_match(token_string, str8_lit("?"), 0) && 13 <= max_precedence) { + it += 1; + // rjf: parse middle expression E_TokenArray middle_expr_tokens = e_token_array_make_first_opl(it, it_opl); E_Parse middle_expr_parse = e_parse_expr_from_text_tokens__prec(arena, text, &middle_expr_tokens, e_max_precedence); @@ -1845,6 +1847,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to } // rjf: build ternary + if(atom != &e_expr_nil && + middle_expr_parse.expr != &e_expr_nil && + rhs_expr_parse.expr != &e_expr_nil) { E_Expr *lhs = atom; E_Expr *mhs = middle_expr_parse.expr;