Start adding support for runtime errors:
- Primitives can now signal an error. - An error prints a callstack and ends the current (and right now only) fiber. - Arithmetic operators error if the operand is not a number. - Real error for method not found. - Associate source file name, and method names with functions. - Debug line number info for functions. Unfortunately, this regresses perf on fib about 15%, mostly because of the better checking in arithmetic ops. There's still a bunch of clean up to do, but this is a big step in the right direction.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class Foo {}
|
||||
|
||||
(new Foo).someUnknownMethod // expect runtime error: Receiver does not implement method 'someUnknownMethod'.
|
||||
@@ -0,0 +1 @@
|
||||
1 / false // expect runtime error: TypeError: Right operand must be Num.
|
||||
@@ -0,0 +1 @@
|
||||
1 - false // expect runtime error: TypeError: Right operand must be Num.
|
||||
@@ -0,0 +1 @@
|
||||
1 % false // expect runtime error: TypeError: Right operand must be Num.
|
||||
@@ -0,0 +1 @@
|
||||
1 * false // expect runtime error: TypeError: Right operand must be Num.
|
||||
@@ -0,0 +1,3 @@
|
||||
1 + false // expect runtime error: TypeError: Right operand must be Num.
|
||||
|
||||
// TODO: What about a string on the RHS?
|
||||
Reference in New Issue
Block a user