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
822822 "#
823823 ) ) ;
824824 }
825+
825826 #[ test]
826827 fn test_issue_393 ( ) {
827828 let mut ws = VirtualWorkspace :: new ( ) ;
@@ -840,4 +841,21 @@ return t
840841 "#
841842 ) ) ;
842843 }
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+ }
843861}
Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ fn resolve_signature_by_args(
8686 jump_param = 0 ;
8787 } ;
8888
89+ // 如果在不计算可空参数的情况下, 参数数量完全匹配, 则认为其权重更高
90+ if params. len ( ) == fake_expr_len {
91+ total_weight += params. len ( ) as i32 + 1 ;
92+ }
93+
8994 // 冒号定义且冒号调用
9095 if is_colon_call && func. is_colon_define ( ) {
9196 total_weight += 100 ;
You can’t perform that action at this time.
0 commit comments