fix: keep M7 return context through if branches
This commit is contained in:
+7
-9
@@ -866,14 +866,6 @@ static void m7_check_stmt(FeCheckerState *s, FeNode *n)
|
||||
m7_check_if_let(s,n);
|
||||
else {
|
||||
FeType *cond;
|
||||
cond=m7_check_expr(s,n->a);
|
||||
if (known(cond) && cond->kind!=FE_TYPE_BOOL)
|
||||
err(s->c,n->loc,"if condition must be bool");
|
||||
/* Reuse the verified branch merge by letting the M6 statement
|
||||
machinery handle branches that contain no M7-only nodes. */
|
||||
if (!m7_node_feature(n->b) && !m7_node_feature(n->c))
|
||||
check_stmt(s,n);
|
||||
else {
|
||||
FeFlowSlot base[FE_M7_FLOW_CAP];
|
||||
FeFlowSlot left[FE_M7_FLOW_CAP];
|
||||
FeFlowSlot right[FE_M7_FLOW_CAP];
|
||||
@@ -885,6 +877,13 @@ static void m7_check_stmt(FeCheckerState *s, FeNode *n)
|
||||
FeFlowBorrow *borrow_right;
|
||||
unsigned count;
|
||||
unsigned i;
|
||||
cond=m7_check_expr(s,n->a);
|
||||
if (known(cond) && cond->kind!=FE_TYPE_BOOL)
|
||||
err(s->c,n->loc,"if condition must be bool");
|
||||
/* Once a function is on the M7 checker path, branch bodies must
|
||||
remain on that path as well. In particular, return T inside
|
||||
E!T relies on contextual success construction even when the
|
||||
branch itself contains no surface M7 syntax. */
|
||||
m7_capture_flow(s,base,&own_base,&borrow_base,&count);
|
||||
m7_check_stmt(s,n->b);
|
||||
flow_capture(s->scope,left,count);
|
||||
@@ -913,7 +912,6 @@ static void m7_check_stmt(FeCheckerState *s, FeNode *n)
|
||||
flow_own_merge(base,own_left,own_right,count);
|
||||
flow_borrow_merge(base,borrow_left,borrow_right,count);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FE_N_MATCH:
|
||||
m7_check_match_stmt(s,n);
|
||||
|
||||
Reference in New Issue
Block a user