issue #211 since the up-value carries the type of the local variable, we can safely infer that the result of a get on array is a primitive type

pull/216/head
Dibyendu Majumdar 3 years ago
parent 25dbc31393
commit 9bceadd099

@ -1819,6 +1819,25 @@ end
check(x, 'TOIARRAY', 'IARRAY_GET', 'LEN', 'ADD', 'RETURN', 'RETURN')
print 'Test 86 OK'
-- An upvalue that is an array will yield a primitive value
-- issue #211
do
local x: integer[] = {4}
local y: number[] = {4.2}
local function f()
return x[1] + 1, y[1] + 2.2
end
check(f, 'GETTABUP', 'ADDII', 'GETTABUP', 'ADDFF', 'RETURN', 'RETURN')
local a,b = f()
assert(a == 5)
assert(b == 6.4)
compile(f)
a,b = f()
assert(a == 5)
assert(b == 6.4)
end
print 'Test 87 OK'
for k,v in pairs(opcodes_coverage)
do

@ -19,12 +19,11 @@ end
print 'Ok'
-- issue
--do
-- local function f(x:integer[])
-- return function ()
-- return x[1][1] + 1
-- end
-- end
-- local x = f(table.intarray(3))
-- x()
--end
do
local x: integer[] = {4}
local y: number[] = {4.2}
local function f()
return x[1] + 1, y[1] + 2.2
end
ravi.dumplua(f)
end

Loading…
Cancel
Save