Skip to content

Commit 90c1b77

Browse files
committed
fix infer for ter expr
1 parent b7a7093 commit 90c1b77

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

  • crates/emmylua_code_analysis/src/compilation/analyzer/flow/bind_analyze/exprs

crates/emmylua_code_analysis/src/compilation/analyzer/flow/bind_analyze/exprs/mod.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,31 @@ fn bind_ternary_expr(
161161
let condition = ternary_expr.get_condition_expr()?;
162162
let (true_expr, false_expr) = ternary_expr.get_true_false_exprs()?;
163163

164-
let pre_false = binder.create_branch_label();
165-
bind_condition_expr(binder, condition, current, binder.true_target, pre_false);
166-
let current = finish_flow_label(binder, pre_false, current);
164+
let true_branch_label = binder.create_branch_label();
165+
let false_branch_label = binder.create_branch_label();
166+
167167
bind_condition_expr(
168168
binder,
169-
true_expr,
169+
condition,
170170
current,
171+
true_branch_label,
172+
false_branch_label,
173+
);
174+
175+
let true_branch_start = finish_flow_label(binder, true_branch_label, binder.unreachable);
176+
bind_condition_expr(
177+
binder,
178+
true_expr,
179+
true_branch_start,
171180
binder.true_target,
172181
binder.false_target,
173182
);
183+
184+
let false_branch_start = finish_flow_label(binder, false_branch_label, binder.unreachable);
174185
bind_condition_expr(
175186
binder,
176187
false_expr,
177-
current,
188+
false_branch_start,
178189
binder.true_target,
179190
binder.false_target,
180191
);

0 commit comments

Comments
 (0)