Thanks for the wonderful book, still in the middle of going through it. I found a small bug in the implementation of the LoxArray length returns. This is due to Java's array.length returning an integer rather than a double. The checkNumberOperand checks for Double only. To fix this, we cast the primitive into a double.
To reproduce:
var a = Array(5);
for (var i = 0; i < a.length; i = i+1) {
print i;
}
Thanks for the wonderful book, still in the middle of going through it. I found a small bug in the implementation of the LoxArray length returns. This is due to Java's array.length returning an integer rather than a double. The checkNumberOperand checks for Double only. To fix this, we cast the primitive into a double.
To reproduce:
Will return
Operands must be a number.
as it errors out here: https://github.com/munificent/craftinginterpreters/blob/master/java/com/craftinginterpreters/lox/Interpreter.java#L495