mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Nesting index multiplication assignment fixed
This affects all arithmetic types applied to inner-nested compounds.
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
|
||||
var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
||||
|
||||
var d = ["foo" : ["bar" : ["bazz": ["fizz" : 5]]]];
|
||||
a[1][1] *= 10;
|
||||
|
||||
print d;
|
||||
|
||||
d["foo"]["bar"]["bazz"]["fizz"] = 66;
|
||||
|
||||
print d;
|
||||
print a;
|
||||
@@ -312,7 +312,7 @@ static Toy_Opcode Toy_writeCompilerWithJumps(Toy_Compiler* compiler, Toy_ASTNode
|
||||
//return this if...
|
||||
Toy_Opcode ret = Toy_writeCompilerWithJumps(compiler, node->binary.right, breakAddressesPtr, continueAddressesPtr, jumpOffsets, rootNode);
|
||||
|
||||
if (node->binary.opcode == TOY_OP_INDEX && rootNode->type == TOY_AST_NODE_BINARY && rootNode->binary.opcode == TOY_OP_VAR_ASSIGN) { //why var assign?
|
||||
if (node->binary.opcode == TOY_OP_INDEX && rootNode->type == TOY_AST_NODE_BINARY && (rootNode->binary.opcode >= TOY_OP_VAR_ASSIGN && rootNode->binary.opcode <= TOY_OP_VAR_MODULO_ASSIGN)) { //range-based check for assignment type
|
||||
return TOY_OP_INDEX_ASSIGN_INTERMEDIATE;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,14 @@
|
||||
assert a[0][0] == [42], "nested indexing failed";
|
||||
}
|
||||
|
||||
//test nested indexing multipliciation assignment
|
||||
{
|
||||
var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
||||
|
||||
a[1][1] *= 10;
|
||||
|
||||
assert a == [[1, 2, 3], [4, 50, 6], [7, 8, 9]], "nested indexing multipliciation assignment failed";
|
||||
}
|
||||
|
||||
//test combine example
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user