old_contents: import ljd.ast.nodes as nodes
  
  
  def insert_table_record(constructor, key, value):
  	array = constructor.array.contents
  	records = constructor.records.contents
  
  	if isinstance(key, nodes.MULTRES):
  		assert len(records) == 0 \
  			or isinstance(records[-1], nodes.TableRecord)
  
  		records.append(value)
  		return
  
  	while isinstance(key, nodes.Constant)			\
  				and key.type == key.T_INTEGER	\
  				and key.value >= 0:
  		if key.value > len(array):
  			break
  
  		record = nodes.ArrayRecord()
  		record.value = value
  
  		if key.value == len(array):
  			array.append(record)
  		else:
  			array[key.value] = record
  
  		return
  
  	record = nodes.TableRecord()
  	record.key = key
  	record.value = value
  
  	if len(records) == 0:
  		records.append(record)
  		return
  
  	last = records[-1]
  
  	if isinstance(last, (nodes.FunctionCall, nodes.Vararg)):
  		records.insert(-1, record)
  	else:
  		records.append(record)
  
new_contents: import ljd.ast.nodes as nodes
  
  
  def insert_table_record(constructor, key, value):
  	array = constructor.array.contents
  	records = constructor.records.contents
  
  	if isinstance(key, nodes.MULTRES):
  		assert len(records) == 0 \
  			or isinstance(records[-1], nodes.TableRecord)
  
  		records.append(value)
  		return
  
  	while isinstance(key, nodes.Constant)			\
  				and key.type == key.T_INTEGER	\
  				and key.value >= 0:
  		index = key.value
  		
  		if index == 1 and len(array) == 0:
  			record = nodes.ArrayRecord()
  			record.value = nodes.Primitive()
  			record.value.type = nodes.Primitive.T_NIL
  			
  			array.append(record)
  		
  		if (index > len(array)):
  			break
  
  		record = nodes.ArrayRecord()
  		record.value = value
  
  		if len(array) == 0 or index == len(array):
  			array.append(record)
  		else:
  			array[index] = record
  
  		return
  
  	record = nodes.TableRecord()
  	record.key = key
  	record.value = value
  
  	if len(records) == 0:
  		records.append(record)
  		return
  
  	last = records[-1]
  
  	if isinstance(last, (nodes.FunctionCall, nodes.Vararg)):
  		records.insert(-1, record)
  	else:
  		records.append(record)
  
subject: fix tables with indices starting with 1