'print' now works as expected

String literals are now stored in the bucket mid-compilation, but this
is fine, as the buckets are freed one the bytecode is complete.
This commit is contained in:
2026-04-06 23:08:17 +10:00
parent 1ae3fcbf73
commit f06218b9cd
4 changed files with 20 additions and 3 deletions

View File

@@ -388,7 +388,7 @@ static Toy_AstFlag literal(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_As
buffer[i] = '\0';
unsigned int len = i - escapeCounter; //NOTE: len is ONLY the string length
Toy_private_emitAstValue(bucketHandle, rootHandle, TOY_VALUE_FROM_STRING(Toy_toStringLength(bucketHandle, buffer, len)));
Toy_private_emitAstValue(bucketHandle, rootHandle, TOY_VALUE_FROM_STRING(Toy_createStringLength(bucketHandle, buffer, len))); //BUGFIX: create the string to avoid losing local var 'buffer'
return TOY_AST_FLAG_NONE;
}