From 502032e51402bd0a9db0582b7b0ebe8f8aacd3c8 Mon Sep 17 00:00:00 2001 From: Ratstail91 Date: Sat, 4 Mar 2023 15:41:55 +1100 Subject: [PATCH] Testing an obscure bugfix --- source/toy_interpreter.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/toy_interpreter.c b/source/toy_interpreter.c index c25f367..67b1e14 100644 --- a/source/toy_interpreter.c +++ b/source/toy_interpreter.c @@ -1767,12 +1767,7 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) { assign = Toy_popLiteralArray(&interpreter->stack); } else { - compound = result; - Toy_freeLiteral(result); - - //suppress the extra assign value - Toy_Literal tmp = Toy_popLiteralArray(&interpreter->stack); - Toy_freeLiteral(tmp); + assign = result; } third = Toy_popLiteralArray(&interpreter->stack); @@ -1869,6 +1864,12 @@ static bool execIndexAssign(Toy_Interpreter* interpreter) { Toy_freeLiteralArray(&arguments); } + //BUGFIX: make sure the compound name can be assigned + if (TOY_IS_NULL(compoundIdn)) { + compoundIdn = Toy_popLiteralArray(&interpreter->stack); + freeIdn = true; + } + if (TOY_IS_IDENTIFIER(compoundIdn) && !Toy_setScopeVariable(interpreter->scope, compoundIdn, result, true)) { interpreter->errorOutput("Incorrect type assigned to compound member "); Toy_printLiteralCustom(compoundIdn, interpreter->errorOutput);