summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/vm/value.lua7
-rw-r--r--server/test/type_inference/init.lua3
2 files changed, 10 insertions, 0 deletions
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 625066b1..48b74bee 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -1,6 +1,7 @@
local libraryBuilder = require 'vm.library'
local library = require 'core.library'
local listMgr = require 'vm.list'
+local config = require 'config'
local Sort = 0
local Watch = setmetatable({}, {__mode = 'kv'})
@@ -79,6 +80,12 @@ function mt:setType(tp, rate)
if tp == 'any' or tp == 'nil' then
rate = 0.0
end
+ if tp == 'integer' then
+ local version = config.config.runtime.version
+ if version ~= 'Lua 5.3' and version ~= 'Lua 5.4' then
+ tp = 'number'
+ end
+ end
local current = self._type[tp] or 0.0
self._type[tp] = current + (1 - current) * rate
end
diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua
index a4f95caa..9155b3ed 100644
--- a/server/test/type_inference/init.lua
+++ b/server/test/type_inference/init.lua
@@ -1,6 +1,7 @@
local parser = require 'parser'
local core = require 'core'
local buildVM = require 'vm'
+local config = require 'config'
rawset(_G, 'TEST', true)
@@ -19,6 +20,8 @@ function TEST(res)
end
end
+config.config.runtime.version = 'Lua 5.4'
+
TEST 'string' [[
local <?var?> = '111'
]]