Skip to content

Commit 6cc7f62

Browse files
committed
remove tuple immutable
1 parent f667054 commit 6cc7f62

2 files changed

Lines changed: 20 additions & 39 deletions

File tree

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,6 @@ fn is_valid_member(
172172
match semantic_model.get_semantic_info(index_expr.syntax().clone().into()) {
173173
Some(info) => {
174174
let need = info.semantic_decl.is_none() && info.typ.is_unknown();
175-
// TODO: 元组类型的检查或许需要独立出来
176-
if !need && matches!(code, DiagnosticCode::InjectField) {
177-
if let LuaType::Tuple(tuple) = prefix_typ {
178-
if tuple.is_infer_resolve() {
179-
return Some(());
180-
} else {
181-
// 元组类型禁止修改
182-
return None;
183-
}
184-
}
185-
}
186175
need
187176
}
188177
None => true,
@@ -218,14 +207,6 @@ fn is_valid_member(
218207

219208
// 一些类型组合需要特殊处理
220209
match (prefix_typ, &key_type) {
221-
(LuaType::Tuple(tuple), LuaType::Integer | LuaType::IntegerConst(_)) => {
222-
if tuple.is_infer_resolve() {
223-
return Some(());
224-
} else {
225-
// 元组类型禁止修改
226-
return None;
227-
}
228-
}
229210
(LuaType::Def(id), _) => {
230211
if let Some(decl) = semantic_model.get_db().get_type_index().get_type_decl(id) {
231212
if decl.is_class() {

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,24 @@ mod test {
130130
));
131131
}
132132

133-
#[test]
134-
fn test_tuple() {
135-
let mut ws = VirtualWorkspace::new();
136-
assert!(ws.check_code_for(
137-
DiagnosticCode::InjectField,
138-
r#"
139-
local a = { 'a' }
140-
a[#a + 1] = 'b'
141-
"#
142-
));
143-
144-
assert!(!ws.check_code_for(
145-
DiagnosticCode::InjectField,
146-
r#"
147-
---@type [ 'a' ]
148-
local a = { 'a' }
149-
a[#a + 1] = 'b'
150-
"#
151-
));
152-
}
133+
// #[test]
134+
// fn test_tuple() {
135+
// let mut ws = VirtualWorkspace::new();
136+
// assert!(ws.check_code_for(
137+
// DiagnosticCode::InjectField,
138+
// r#"
139+
// local a = { 'a' }
140+
// a[#a + 1] = 'b'
141+
// "#
142+
// ));
143+
144+
// // assert!(!ws.check_code_for(
145+
// // DiagnosticCode::InjectField,
146+
// // r#"
147+
// // ---@type [ 'a' ]
148+
// // local a = { 'a' }
149+
// // a[#a + 1] = 'b'
150+
// // "#
151+
// // ));
152+
// }
153153
}

0 commit comments

Comments
 (0)