Add internal error handling to VM, plus function arity
* VM is able to handle basic runtime errors although there is no way to catch this in executing code currently * If a function is called with the wrong number of arguments (arity) it will invoke a runtime error. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -42,7 +42,7 @@ impl Compile {
|
||||
sym
|
||||
})
|
||||
.collect();
|
||||
Ok((self.const_data.const_pool, UserFun::new_obj(main, globals)))
|
||||
Ok((self.const_data.const_pool, UserFun::new_obj(main, globals, 0)))
|
||||
}
|
||||
|
||||
/// Gets the constant data that is interned in this compile session.
|
||||
|
||||
@@ -407,7 +407,7 @@ impl Visit for CompileBody<'_> {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let (hdl, _fun) = self.compile.push_const(UserFun::new_obj(code, locals));
|
||||
let (hdl, _fun) = self.compile.push_const(UserFun::new_obj(code, locals, expr.params.len()));
|
||||
|
||||
// TODO(compile) : determine return value at the end of the body (preferably at parse-time)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user