Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/emmylua_code_analysis/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# EmmyLua Code Analysis

EmmyLua Code Analysis is a static analysis tool for Lua code. It can be used to analyze Lua code and provide code completion, type checking, and other features in IDEs.

See the [flow typing contract](../../docs/emmylua_code_analysis/flow-typing.md) for supported flow features and scope limits.
650 changes: 111 additions & 539 deletions crates/emmylua_code_analysis/src/check/checker/assign_type_mismatch.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use emmylua_parser::{
use crate::DiagnosticCode;
use crate::semantic_model::SemanticModel;
use crate::semantic_model::type_check;
use crate::semantic_model::type_check::{TypeCheckFailReason, check_type_detail};
use crate::semantic_model::type_check::check_type_detail;
use crate::{LuaFunctionType, LuaType, LuaTypeDeclId, TypeDef};

use super::{CheckContext, Checker};
Expand Down Expand Up @@ -275,8 +275,9 @@ fn add_type_check_diagnostic(
param_type: &LuaType,
) {
let reason = match check_type_detail(semantic_model, arg_type, param_type) {
Err(TypeCheckFailReason::TypeNotMatchWithReason(reason)) => format!(" {reason}"),
Err(TypeCheckFailReason::TypeNotMatch) => String::new(),
Err(err) if err.is_type_not_match() => err
.reason()
.map_or(String::new(), |reason| format!(" {reason}")),
_ => return,
};
context.add_diagnostic(
Expand Down
Loading
Loading