nibi-lang / nibi

An interpreted list processing language inspired by Lisp
GNU Affero General Public License v3.0
3 stars 2 forks source link

`eval` update #106

Closed bosley closed 1 year ago

bosley commented 1 year ago

Errors from eval command are bad.

We need to override location settings for tokenizer and parser for the intake_c that eval is using.

Perhaps add a function on intake_c that says "eval_override" and give it a start locator for error reporting. That way the user can actually see where the error is

I found this out wth:

(use "io")
(macro sassert_eq [_lhs _rhs _cb]
  ((fn [] 
    (if (eq %_lhs %_rhs) 
      (<- true) 
      [
        (if (eq %_cb nil) (<- false) [ (%_cb %_lhs %_rhs) (<- false) ] )
        (<- false)
      ]

    ))))

(io::println ">>>" (sassert_eq 1 2 nil))
(io::println "COMPLETE")

%_cb is evaluated to nil so this was programmer error as nil is not a function or a symbol, but nil literally, but the error was :

Message: Invalid instruction list - Expected symbol, access list, or instruction list

with some random ass locator.

This relates to eval as the body of a macro is stringed and then, when called, executed via eval

We need the locators generated to offset correctly to index into where the macro is defined, or utilized. It just needs to make sense and help the user understand what went down. right now its the wild west when this occurs.

bosley commented 1 year ago

https://github.com/nibi-lang/nibi/pull/134