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 3434 print (x ) -- `x` is `string` here
3535 end
3636 ```
37+ * ` CHG ` infer type by ` > ` /` < ` /` >= ` /` <= `
3738* ` FIX ` with clients that support LSP 3.17 (VSCode), workspace diagnostics are triggered every time when opening a file.
3839* ` FIX ` [ #1204 ] ( https://github.com/sumneko/lua-language-server/issues/1204 )
3940* ` 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()
17861786 return
17871787 end
17881788 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
17891819 end )
17901820
17911821--- @param source vm.object
Original file line number Diff line number Diff line change @@ -154,6 +154,10 @@ TEST 'integer' [[
154154<?x?> = ~ 1
155155]]
156156
157+ TEST ' boolean' [[
158+ <?x?> = 1 < 2
159+ ]]
160+
157161TEST ' integer' [[
158162local a = true
159163local b = 1
You can’t perform that action at this time.
0 commit comments