Skip to content

Commit 4a33e15

Browse files
committed
add _ENV annotation
1 parent 38f7ec6 commit 4a33e15

File tree

2 files changed

+9
-4
lines changed
  • crates/emmylua_code_analysis

2 files changed

+9
-4
lines changed

crates/emmylua_code_analysis/resources/std/global.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,9 @@ function warn(message) end
405405

406406
---@type string[]
407407
arg = {}
408+
409+
--- This is an incorrect annotation, but truly supporting _ENV would completely break the variable analysis path.
410+
--- For now, let's treat it as a global variable.
411+
---@version > 5.3
412+
---@type global
413+
_ENV = {}

crates/emmylua_code_analysis/src/compilation/analyzer/flow/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn flow_analyze(db: &mut DbIndex, file_id: FileId, root: LuaChunk) -> Option<()>
2121
let references_index = db.get_reference_index();
2222
let refs_map = references_index.get_decl_references_map(&file_id)?.clone();
2323

24-
let mut analyzer = FlowAnalyzer::new(db, file_id, root.clone());
24+
let mut analyzer = FlowAnalyzer::new(db, root.clone());
2525
for (decl_id, decl_refs) in refs_map {
2626
let mut flow_chains = LuaFlowChain::new(decl_id);
2727

@@ -55,13 +55,12 @@ fn flow_analyze(db: &mut DbIndex, file_id: FileId, root: LuaChunk) -> Option<()>
5555

5656
#[derive(Debug)]
5757
struct FlowAnalyzer<'a> {
58-
file_id: FileId,
5958
db: &'a mut DbIndex,
6059
root: LuaChunk,
6160
}
6261

6362
impl FlowAnalyzer<'_> {
64-
pub fn new<'a>(db: &'a mut DbIndex, file_id: FileId, root: LuaChunk) -> FlowAnalyzer<'a> {
65-
FlowAnalyzer { file_id, db, root }
63+
pub fn new<'a>(db: &'a mut DbIndex, root: LuaChunk) -> FlowAnalyzer<'a> {
64+
FlowAnalyzer { db, root }
6665
}
6766
}

0 commit comments

Comments
 (0)