Currently, the interpreter often prints not very helpful error messages like wrong data types for operator. Make the error messages better
The line and column should be included
The line should be printed, ideally the exact place where it happened should be underlined.
Tips for how to fix given error can also be included, if it is a simple fix.
For example
Runtime error; 15:18: Wrong types for operator `&&`, expected boolean, got int
if (is_even(x) && x) {
^
Suggestion: Try x != 0
This would be ideal, but anything better that what is there currently is fine. At the very least the location and line should be printed.
This will require passing the source file to the VM, and also a array of every instruction index corresponding to a place in the source code. Only character index in the file should be passed (not line and column). The VM will then open the file and find it manually. This can be slow but it is not a concern, since it'll happen only when error happens.
Currently, the interpreter often prints not very helpful error messages like
wrong data types for operator
. Make the error messages betterFor example
This would be ideal, but anything better that what is there currently is fine. At the very least the location and line should be printed.
This will require passing the source file to the VM, and also a array of every instruction index corresponding to a place in the source code. Only character index in the file should be passed (not line and column). The VM will then open the file and find it manually. This can be slow but it is not a concern, since it'll happen only when error happens.