Skip to content

Commit a0da94d

Browse files
committed
disable loop stat narrow outside
1 parent 2eb92e8 commit a0da94d

File tree

2 files changed

+25
-3
lines changed
  • crates/emmylua_code_analysis/src/compilation

2 files changed

+25
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn bind_while_stat(
248248
);
249249
}
250250

251-
finish_flow_label(binder, post_while_label, current)
251+
current
252252
}
253253

254254
pub fn bind_repeat_stat(
@@ -369,7 +369,7 @@ pub fn bind_for_range_stat(
369369
);
370370
}
371371

372-
finish_flow_label(binder, post_for_range_label, current)
372+
current
373373
}
374374

375375
pub fn bind_for_stat(binder: &mut FlowBinder, for_stat: LuaForStat, current: FlowId) -> FlowId {
@@ -389,5 +389,5 @@ pub fn bind_for_stat(binder: &mut FlowBinder, for_stat: LuaForStat, current: Flo
389389
bind_iter_block(binder, iter_block, for_node, pre_for_label, post_for_label);
390390
}
391391

392-
finish_flow_label(binder, post_for_label, current)
392+
current
393393
}

crates/emmylua_code_analysis/src/compilation/test/flow.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,4 +869,26 @@ end
869869
"#,
870870
);
871871
}
872+
873+
#[test]
874+
fn test_issue_584() {
875+
let mut ws = VirtualWorkspace::new_with_init_std_lib();
876+
877+
ws.check_code_for(
878+
DiagnosticCode::AssignTypeMismatch,
879+
r#"
880+
local function foo()
881+
for _ in ipairs({}) do
882+
break
883+
end
884+
885+
local a
886+
if a == nil then
887+
a = 1
888+
local _ = a --- @type integer
889+
end
890+
end
891+
"#,
892+
);
893+
}
872894
}

0 commit comments

Comments
 (0)