diff options
-rw-r--r-- | make/bootstrap.lua | 3 | ||||
-rw-r--r-- | script/core/diagnostics/need-check-nil.lua | 2 | ||||
-rw-r--r-- | script/vm/compiler.lua | 3 | ||||
-rw-r--r-- | script/vm/infer.lua | 20 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 7 | ||||
-rw-r--r-- | test/type_inference/init.lua | 4 |
6 files changed, 26 insertions, 13 deletions
diff --git a/make/bootstrap.lua b/make/bootstrap.lua index 6c27cf95..00036f34 100644 --- a/make/bootstrap.lua +++ b/make/bootstrap.lua @@ -69,6 +69,9 @@ package.searchers[2] = function (name) return err
end
local f = io.open(filename)
+ if not f then
+ return 'cannot open file:' .. filename
+ end
local buf = f:read '*a'
f:close()
local relative = filename:sub(1, #root) == root and filename:sub(#root + 2) or filename
diff --git a/script/core/diagnostics/need-check-nil.lua b/script/core/diagnostics/need-check-nil.lua index 8654a7a6..98fdfd08 100644 --- a/script/core/diagnostics/need-check-nil.lua +++ b/script/core/diagnostics/need-check-nil.lua @@ -32,7 +32,7 @@ return function (uri, callback) callback { start = src.start, finish = src.finish, - message = lang.script('DIAG_MISS_NEED_CHECK_NIL'), + message = lang.script('DIAG_NEED_CHECK_NIL'), } end end) diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 1f33a784..c69a7724 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1435,8 +1435,7 @@ local compilerSwitch = util.switch() elseif r1 == false then vm.setNode(source, node1) else - vm.getNode(source):merge(node2) - vm.getNode(source):addOptional() + vm.setNode(source, node2) end end if source.op.type == 'or' then diff --git a/script/vm/infer.lua b/script/vm/infer.lua index b5e717d5..410f9795 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -294,10 +294,6 @@ function mt:view(default, uri) end end - if #array == 0 then - return default or 'unknown' - end - table.sort(array, function (a, b) local sa = inferSorted[a] or 0 local sb = inferSorted[b] or 0 @@ -311,13 +307,17 @@ function mt:view(default, uri) local limit = config.get(uri or self.uri, 'Lua.hover.enumsLimit') local view - if max > limit then - view = string.format('%s...(+%d)' - , table.concat(array, '|', 1, limit) - , max - limit - ) + if #array == 0 then + view = default or 'unknown' else - view = table.concat(array, '|') + if max > limit then + view = string.format('%s...(+%d)' + , table.concat(array, '|', 1, limit) + , max - limit + ) + else + view = table.concat(array, '|') + end end if self.node:isOptional() then diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 72b2db6c..5f1d01c8 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1494,3 +1494,10 @@ local x S = <!x!>() ]] + +TEST [[ +local x, y +local z = x and y + +print(z.y) +]] diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 64cc43a8..a9ea81a7 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -1915,3 +1915,7 @@ local t local <?x?> = t[1] ]] + +TEST 'unknown' [[ +local <?x?> = y and z +]] |