At the end of chapter 20, we store strings in the vm's internal hash table. This works great, except when we want to concatenate multiple new strings in one line, which leads to a segmentation fault. As far as I can tell that is due to the last string not having been committed to the table before.
So this code leads to an error state:
print "a" + "b";
print "a" + "b" + "c"; // no seg fault, as we already know the string "ab"
print "x" + "y" + "z";
This is the output from Lox with debug information
Disclaimer: There's a decent chance that I made a mistake, in which case I would be grateful for pointers. I already spent an ungodly amount of time on this 💯
At the end of chapter 20, we store strings in the vm's internal hash table. This works great, except when we want to concatenate multiple new strings in one line, which leads to a segmentation fault. As far as I can tell that is due to the last string not having been committed to the table before.
So this code leads to an error state:
This is the output from Lox with debug information
For reference, this is my current working state
Disclaimer: There's a decent chance that I made a mistake, in which case I would be grateful for pointers. I already spent an ungodly amount of time on this 💯