Skip to content

Commit b65a0d3

Browse files
committed
Fix goto after error
1 parent 690fd58 commit b65a0d3

File tree

1 file changed

+7
-2
lines changed
  • crates/emmylua_code_analysis/src/compilation/analyzer/flow/bind_analyze

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ pub fn bind_analyze(binder: &mut FlowBinder, chunk: LuaChunk) -> Option<()> {
3333

3434
fn bind_block(binder: &mut FlowBinder, block: LuaBlock, current: FlowId) -> FlowId {
3535
let mut return_flow_id = current;
36+
let mut can_change_flow = true;
3637
for node in block.children::<LuaAst>() {
37-
return_flow_id = bind_node(binder, node, return_flow_id);
38+
let node_flow_id = bind_node(binder, node, return_flow_id);
39+
if can_change_flow {
40+
return_flow_id = node_flow_id;
41+
}
42+
3843
if let Some(flow_node) = binder.get_flow(return_flow_id) {
3944
match &flow_node.kind {
4045
FlowNodeKind::Return | FlowNodeKind::Break => {
4146
return_flow_id = binder.unreachable;
42-
break;
47+
can_change_flow = false;
4348
}
4449
_ => {}
4550
}

0 commit comments

Comments
 (0)