Skip to content

Commit 2a2f627

Browse files
committed
Release 0.7.3
Fix #478
1 parent 82e57f3 commit 2a2f627

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CHANGELOG
22

3-
# 0.7.3(unreleased)
3+
# 0.8.0 (unreleased)
4+
5+
# 0.7.3
46

57
`FIX` Fix a crash issue
68

crates/emmylua_code_analysis/src/compilation/analyzer/flow/var_analyze/broadcast_up.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,17 @@ pub fn broadcast_up_and(
240240
return Some(());
241241
}
242242
} else {
243+
// disable b broadcast_up in `a and <b> or c``
244+
if let Some(parent_binary) = binary_expr.get_parent::<LuaBinaryExpr>() {
245+
let op = parent_binary.get_op_token()?;
246+
match op.get_op() {
247+
BinaryOperator::OpOr => {
248+
return None;
249+
}
250+
_ => {}
251+
}
252+
}
253+
243254
let left_id = UnResolveTraceId::Expr(left);
244255
if let Some(left_unresolve_trace_info) = var_trace.pop_unresolve_trace(&left_id) {
245256
let left_trace_info = left_unresolve_trace_info.1.get_trace_info()?;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,4 +743,21 @@ end
743743
"#
744744
))
745745
}
746+
747+
#[test]
748+
fn test_issue_478() {
749+
let mut ws = VirtualWorkspace::new();
750+
751+
assert!(ws.check_code_for(
752+
DiagnosticCode::ReturnTypeMismatch,
753+
r#"
754+
--- @param line string
755+
--- @param b boolean
756+
--- @return string
757+
function foo(line, b)
758+
return b and line or line
759+
end
760+
"#
761+
));
762+
}
746763
}

0 commit comments

Comments
 (0)