Table.copy() range parameters are wrong

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Table.copy() range parameters are wrong

danilafoxpro
According to documentation, Table.copy(table) should be equivalent to Table.copy(table, 1, #table). Yet that is not the case:
local Luan = require "luan:Luan.luan"
local error = Luan.error
local Table = require "luan:Table.luan"
local table_copy = Table.copy or error()

local table = {
	1
	2
	3
}

local table1 = table_copy(table)
local table2 = table_copy(table, 1, #table)

#table1 == #table2 or error("Size mismatch!")

I believe mistake is on line 423 of 'src/luan/LuanTable.java'. '1' shouldn't be subtracted from 'to', because subArray()'s toIndex parameter is exclusive.
Reply | Threaded
Open this post in threaded view
|

Re: Table.copy() range parameters are wrong

fschmidt
Administrator
yes, fixed