Skip to content

Commit 089da9f

Browse files
committed
fix diagnostic: generic_type TypeNotFound
1 parent 8fe6a1b commit 089da9f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

crates/emmylua_code_analysis/src/compilation/analyzer/doc/infer_type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ fn infer_generic_type(analyzer: &mut DocAnalyzer, generic_type: &LuaDocGenericTy
215215
{
216216
name_type_decl.get_id()
217217
} else {
218+
analyzer.db.get_diagnostic_index_mut().add_diagnostic(
219+
analyzer.file_id,
220+
AnalyzeError::new(
221+
DiagnosticCode::TypeNotFound,
222+
&t!("Type '%{name}' not found", name = name),
223+
generic_type.get_range(),
224+
),
225+
);
218226
return LuaType::Unknown;
219227
};
220228

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,16 @@ mod test {
112112
let expected = ws.ty("string");
113113
assert_eq!(ty, expected);
114114
}
115+
116+
#[test]
117+
fn test_generic_type_inference() {
118+
let mut ws = VirtualWorkspace::new();
119+
120+
assert!(!ws.check_code_for(
121+
DiagnosticCode::TypeNotFound,
122+
r#"
123+
---@class AnonymousObserver<T>: Observer<T>
124+
"#,
125+
));
126+
}
115127
}

crates/emmylua_code_analysis/src/config/configs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod code_action;
22
mod codelen;
33
mod completion;
44
mod diagnostics;
5+
mod doc;
56
mod document_color;
67
mod hover;
78
mod inlayhint;
@@ -13,12 +14,12 @@ mod semantictoken;
1314
mod signature;
1415
mod strict;
1516
mod workspace;
16-
mod doc;
1717

1818
pub use code_action::EmmyrcCodeAction;
1919
pub use codelen::EmmyrcCodeLen;
2020
pub use completion::{EmmyrcCompletion, EmmyrcFilenameConvention};
2121
pub use diagnostics::EmmyrcDiagnostic;
22+
pub use doc::EmmyrcDoc;
2223
pub use document_color::EmmyrcDocumentColor;
2324
pub use hover::EmmyrcHover;
2425
pub use inlayhint::EmmyrcInlayHint;
@@ -30,4 +31,3 @@ pub use semantictoken::EmmyrcSemanticToken;
3031
pub use signature::EmmyrcSignature;
3132
pub use strict::EmmyrcStrict;
3233
pub use workspace::EmmyrcWorkspace;
33-
pub use doc::EmmyrcDoc;

0 commit comments

Comments
 (0)