File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 34
34
print (x ) -- `x` is `string` here
35
35
end
36
36
```
37
+ * ` CHG ` infer type by ` > ` /` < ` /` >= ` /` <= `
37
38
* ` FIX ` with clients that support LSP 3.17 (VSCode), workspace diagnostics are triggered every time when opening a file.
38
39
* ` FIX ` [ #1204 ] ( https://github.com/sumneko/lua-language-server/issues/1204 )
39
40
* ` FIX ` [ #1208 ] ( https://github.com/sumneko/lua-language-server/issues/1208 )
Original file line number Diff line number Diff line change @@ -1786,6 +1786,36 @@ local compilerSwitch = util.switch()
1786
1786
return
1787
1787
end
1788
1788
end
1789
+ if source .op .type == ' >'
1790
+ or source .op .type == ' <'
1791
+ or source .op .type == ' >='
1792
+ or source .op .type == ' <=' then
1793
+ local a = vm .getNumber (source [1 ])
1794
+ local b = vm .getNumber (source [2 ])
1795
+ if a and b then
1796
+ local result
1797
+ if source .op .type == ' >' then
1798
+ result = a > b
1799
+ elseif source .op .type == ' <' then
1800
+ result = a < b
1801
+ elseif source .op .type == ' >=' then
1802
+ result = a >= b
1803
+ elseif source .op .type == ' <=' then
1804
+ result = a <= b
1805
+ end
1806
+ vm .setNode (source , {
1807
+ type = ' boolean' ,
1808
+ start = source .start ,
1809
+ finish = source .finish ,
1810
+ parent = source ,
1811
+ [1 ] = result ,
1812
+ })
1813
+ return
1814
+ else
1815
+ vm .setNode (source , vm .declareGlobal (' type' , ' boolean' ))
1816
+ return
1817
+ end
1818
+ end
1789
1819
end )
1790
1820
1791
1821
--- @param source vm.object
Original file line number Diff line number Diff line change @@ -154,6 +154,10 @@ TEST 'integer' [[
154
154
<?x?> = ~ 1
155
155
]]
156
156
157
+ TEST ' boolean' [[
158
+ <?x?> = 1 < 2
159
+ ]]
160
+
157
161
TEST ' integer' [[
158
162
local a = true
159
163
local b = 1
You can’t perform that action at this time.
0 commit comments