File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
crates/emmylua_code_analysis/src
semantic/overload_resolve Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -822,6 +822,7 @@ return t
822
822
"#
823
823
) ) ;
824
824
}
825
+
825
826
#[ test]
826
827
fn test_issue_393 ( ) {
827
828
let mut ws = VirtualWorkspace :: new ( ) ;
@@ -840,4 +841,21 @@ return t
840
841
"#
841
842
) ) ;
842
843
}
844
+
845
+ #[ test]
846
+ fn test_issue_374 ( ) {
847
+ let mut ws = VirtualWorkspace :: new ( ) ;
848
+ assert ! ( ws. check_code_for(
849
+ DiagnosticCode :: AssignTypeMismatch ,
850
+ r#"
851
+ --- @param x? integer
852
+ --- @return integer?
853
+ --- @overload fun(): integer
854
+ function bar(x) end
855
+
856
+ --- @type integer
857
+ local _ = bar() -- - error cannot assign `integer?` to `integer`
858
+ "#
859
+ ) ) ;
860
+ }
843
861
}
Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ fn resolve_signature_by_args(
86
86
jump_param = 0 ;
87
87
} ;
88
88
89
+ // 如果在不计算可空参数的情况下, 参数数量完全匹配, 则认为其权重更高
90
+ if params. len ( ) == fake_expr_len {
91
+ total_weight += params. len ( ) as i32 + 1 ;
92
+ }
93
+
89
94
// 冒号定义且冒号调用
90
95
if is_colon_call && func. is_colon_define ( ) {
91
96
total_weight += 100 ;
You can’t perform that action at this time.
0 commit comments