We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6939d67 commit 26b67ecCopy full SHA for 26b67ec
2 files changed
crates/emmylua_code_analysis/src/diagnostic/checker/check_field.rs
@@ -64,6 +64,11 @@ fn check_index_expr(
64
let prefix_typ = semantic_model
65
.infer_expr(index_expr.get_prefix_expr()?)
66
.unwrap_or(LuaType::Unknown);
67
+
68
+ if !is_valid_prefix_type(&prefix_typ) {
69
+ return Some(());
70
+ }
71
72
let index_name = index_key.get_path_part();
73
match code {
74
DiagnosticCode::InjectField => {
crates/emmylua_code_analysis/src/diagnostic/test/missing_fields_test.rs
@@ -149,4 +149,18 @@ foo({})
149
"#
150
));
151
}
152
153
+ #[test]
154
+ fn test_1() {
155
+ let mut ws = VirtualWorkspace::new();
156
+ assert!(ws.check_code_for(
157
+ DiagnosticCode::MissingFields,
158
+ r#"
159
+ ---@type table
160
+ local a = {}
161
162
+ print(a[1])
163
+ "#
164
+ ));
165
166
0 commit comments