Skip to content

Commit aaa86db

Browse files
committed
fix pr
1 parent bc37072 commit aaa86db

File tree

9 files changed

+25
-20
lines changed

9 files changed

+25
-20
lines changed

crates/emmylua_code_analysis/resources/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
},
143143
"strict": {
144144
"default": {
145-
"arrayIndex": false,
145+
"arrayIndex": true,
146146
"metaOverrideFileDefine": true,
147147
"requirePath": false,
148148
"typeCall": false
@@ -850,7 +850,7 @@
850850
"properties": {
851851
"arrayIndex": {
852852
"description": "Whether to enable strict mode array indexing.",
853-
"default": false,
853+
"default": true,
854854
"type": "boolean"
855855
},
856856
"metaOverrideFileDefine": {

crates/emmylua_code_analysis/resources/std/debug.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function debug.traceback(thread, message, level) end
316316
--- access a same external local variable) will return identical ids for those
317317
--- upvalue indices.
318318
---@version >5.2, JIT
319-
---@param f async fun(...):any...
319+
---@param f function
320320
---@param n integer
321321
---@return lightuserdata id
322322
---@nodiscard

crates/emmylua_code_analysis/src/compilation/analyzer/flow/var_analyze/var_trace.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ impl<'a> VarTrace<'a> {
9292
old_info.1.add_trace_info(trace_info);
9393
} else {
9494
let trace_info = UnResolveTraceInfo::Trace(trace_info);
95-
self.unresolve_traces
96-
.insert(trace_id, (self.current_flow_id.unwrap(), trace_info));
95+
if let Some(flow_id) = self.current_flow_id {
96+
self.unresolve_traces
97+
.insert(trace_id, (flow_id, trace_info));
98+
}
9799
}
98100
}
99101

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fn default_true() -> bool {
55
true
66
}
77

8+
#[allow(dead_code)]
89
fn default_false() -> bool {
910
false
1011
}
@@ -18,7 +19,7 @@ pub struct EmmyrcStrict {
1819
#[serde(default)]
1920
pub type_call: bool,
2021
/// Whether to enable strict mode array indexing.
21-
#[serde(default = "default_false")]
22+
#[serde(default = "default_true")]
2223
pub array_index: bool,
2324
/// meta define overrides file define
2425
#[serde(default = "default_true")]
@@ -30,7 +31,7 @@ impl Default for EmmyrcStrict {
3031
Self {
3132
require_path: false,
3233
type_call: false,
33-
array_index: false,
34+
array_index: true,
3435
meta_override_file_define: true,
3536
}
3637
}

crates/emmylua_code_analysis/src/db_index/type/type_decl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl LuaTypeDecl {
147147
}
148148
}
149149

150-
pub fn get_alias(&self) -> Option<&LuaType> {
150+
pub fn get_alias_ref(&self) -> Option<&LuaType> {
151151
match &self.extra {
152152
LuaTypeExtra::Alias { origin, .. } => origin.as_ref(),
153153
_ => None,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn is_nullable(db: &DbIndex, typ: &LuaType) -> bool {
254254
LuaType::Ref(decl_id) => {
255255
if let Some(decl) = db.get_type_index().get_type_decl(decl_id) {
256256
if decl.is_alias() {
257-
if let Some(alias_origin) = decl.get_alias() {
257+
if let Some(alias_origin) = decl.get_alias_ref() {
258258
stack.push(alias_origin);
259259
}
260260
}

crates/emmylua_code_analysis/src/diagnostic/lua_diagnostic_code.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub fn get_default_severity(code: DiagnosticCode) -> DiagnosticSeverity {
109109
DiagnosticCode::InjectFieldFail => DiagnosticSeverity::ERROR,
110110
DiagnosticCode::UnreachableCode => DiagnosticSeverity::HINT,
111111
DiagnosticCode::Unused => DiagnosticSeverity::HINT,
112+
DiagnosticCode::UndefinedGlobal => DiagnosticSeverity::ERROR,
112113
DiagnosticCode::Deprecated => DiagnosticSeverity::HINT,
113114
DiagnosticCode::AccessInvisible => DiagnosticSeverity::WARNING,
114115
DiagnosticCode::DiscardReturns => DiagnosticSeverity::WARNING,

crates/emmylua_code_analysis/src/semantic/type_check/ref_type.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@ pub fn check_ref_type_compact(
178178
{
179179
let is_match = enum_fields.get_types().iter().all(|field| {
180180
let next_guard = check_guard.next_level();
181-
if next_guard.is_err() {
182-
return false;
181+
match next_guard {
182+
Ok(guard) => {
183+
check_general_type_compact(db, &source, field, guard).is_ok()
184+
}
185+
Err(_) => return false,
183186
}
184-
check_general_type_compact(db, &source, field, next_guard.unwrap())
185-
.is_ok()
186187
});
187188
if is_match {
188189
return Ok(());

crates/emmylua_code_analysis/src/semantic/type_check/simple_type.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn get_alias_real_type<'a>(db: &'a DbIndex, compact_type: &'a LuaType) -> Option
230230
LuaType::Ref(type_decl_id) => {
231231
let type_decl = db.get_type_index().get_type_decl(type_decl_id)?;
232232
if type_decl.is_alias() {
233-
return get_alias_real_type(db, type_decl.get_alias()?);
233+
return get_alias_real_type(db, type_decl.get_alias_ref()?);
234234
}
235235
Some(compact_type)
236236
}
@@ -250,10 +250,10 @@ fn check_base_type_for_ref_compact(
250250
LuaType::MultiLineUnion(multi_line_union) => {
251251
if multi_line_union.get_unions().iter().all(|(t, _)| {
252252
let next_guard = check_guard.next_level();
253-
if next_guard.is_err() {
254-
return false;
253+
match next_guard {
254+
Ok(guard) => check_general_type_compact(db, source, t, guard).is_ok(),
255+
Err(_) => return false,
255256
}
256-
check_general_type_compact(db, source, t, next_guard.unwrap()).is_ok()
257257
}) {
258258
return Ok(());
259259
}
@@ -291,10 +291,10 @@ fn check_enum_fields_match_source(
291291
if let Some(LuaType::Union(enum_fields)) = decl.get_enum_field_type(db) {
292292
let is_match = enum_fields.get_types().iter().all(|field| {
293293
let next_guard = check_guard.next_level();
294-
if next_guard.is_err() {
295-
return false;
294+
match next_guard {
295+
Ok(guard) => check_general_type_compact(db, source, field, guard).is_ok(),
296+
Err(_) => return false,
296297
}
297-
check_general_type_compact(db, source, field, next_guard.unwrap()).is_ok()
298298
});
299299
if is_match {
300300
return Ok(());

0 commit comments

Comments
 (0)