Skip to content

Commit 18e91c4

Browse files
committed
fix diagnostic MissingFields
1 parent 0153829 commit 18e91c4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

crates/emmylua_code_analysis/src/diagnostic/checker/missing_fields.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ fn check_table_expr(
4444
LuaType::Table | LuaType::Userdata => {
4545
return Some(());
4646
}
47+
LuaType::TableGeneric(_) => {
48+
return Some(());
49+
}
4750
_ => {}
4851
}
4952
}

crates/emmylua_code_analysis/src/diagnostic/test/missing_fields_test.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,27 @@ foo({})
236236
"#
237237
));
238238
}
239+
240+
#[test]
241+
fn test_union_table_generic() {
242+
let mut ws = VirtualWorkspace::new();
243+
ws.def(
244+
r#"
245+
---@class RingBuffer<T>
246+
---@field a number
247+
248+
---@class LiveList<T>
249+
---@field list table<integer, T> | RingBuffer<T>
250+
"#,
251+
);
252+
assert!(ws.check_code_for(
253+
DiagnosticCode::MissingFields,
254+
r#"
255+
---@type LiveList
256+
local LiveList
257+
258+
LiveList.list = {}
259+
"#
260+
));
261+
}
239262
}

0 commit comments

Comments
 (0)