Hi
Assignment to const causes panic instead of expected TypeError
const number = 42;
try {
number = 99;
} catch (err) {
console.log(err);
// expected output: TypeError: invalid assignment to const `number'
// Note - error messages will vary depending on browser
}
console.log(number);
// expected output: 42
thanks
There's a TODO mark for many of the methods in environment module. Are they supposed return ResultValue to indicate success or a failure so that the call sites can be notified upon errors and can handle them appropriately?
@HalidOdat could you verify this? Thanks.
There's a TODO mark for many of the methods in environment module. Are they supposed return
ResultValueto indicate success or a failure so that the call sites can be notified upon errors and can handle them appropriately?@HalidOdat could you verify this? Thanks.
Yes. the environments were set up before exceptions (TypeError, ReferenceError, etc), one way of solving this is to use ResultValue this would require the Interpreter to be passed to every call. Another way is to create a Error enum, that contains, the error type and message and return Result<TheNormalReturntype, Error>, and when we call those function when we need to throw we convert them to a javascript Error (TypeError, RangeError, etc) type. This has the advantage that we dont need to introduce the interpreter to the environments
Thanks for confirming this and suggesting the approach. Could I take this up?
Thanks for confirming this and suggesting the approach. Could I take this up?
sure! :)
@54k1 let us know if you need any further guidance.