File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
crates/emmylua_code_analysis/src/compilation/test Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -1104,4 +1104,58 @@ end
11041104 "# ,
11051105 ) ) ;
11061106 }
1107+
1108+ #[ test]
1109+ fn test_issue_622 ( ) {
1110+ let mut ws = VirtualWorkspace :: new ( ) ;
1111+ ws. def (
1112+ r#"
1113+ ---@class Test.A
1114+ ---@field base number
1115+ ---@field add number
1116+ T = {}
1117+
1118+ ---@enum Test.op
1119+ Op = {
1120+ base = "base",
1121+ add = "add",
1122+ };
1123+ "# ,
1124+ ) ;
1125+ ws. def (
1126+ r#"
1127+ ---@param op Test.op
1128+ ---@param value number
1129+ ---@return boolean
1130+ function T:SetValue(op, value)
1131+ local oldValue = self[op]
1132+ if oldValue == value then
1133+ return false
1134+ end
1135+ A = oldValue
1136+ return true
1137+ end
1138+ "# ,
1139+ ) ;
1140+ let a = ws. expr_ty ( "A" ) ;
1141+ assert_eq ! ( ws. humanize_type( a) , "number" ) ;
1142+ }
1143+
1144+ #[ test]
1145+ fn test_nil_1 ( ) {
1146+ let mut ws = VirtualWorkspace :: new ( ) ;
1147+ ws. def (
1148+ r#"
1149+ ---@type number?
1150+ local angle
1151+
1152+ if angle ~= nil and angle >= 0 then
1153+ A = angle
1154+ end
1155+
1156+ "# ,
1157+ ) ;
1158+ let a = ws. expr_ty ( "A" ) ;
1159+ assert_eq ! ( ws. humanize_type( a) , "number" ) ;
1160+ }
11071161}
You can’t perform that action at this time.
0 commit comments