~technomancy/fennel#164: 
,reload should report reloading errors via the on-error callback

Right now the ,reload command upon re-requering the module returns errors via the on-values callback:

(let [_ (tset package.loaded module-name nil)
      (ok new) (pcall require module-name)
      ;; keep the old module if reload failed
      new (if (not ok)
              (do
                (on-values [new]) ; should be on-error here?
                old)
              new)]
  ...)

This causes the problem that if the REPL defines a custom on-error handler, it completely misses this error.

I guess this is done because the error from require is already composed, e.g. it already contains the full message, which makes it hard to pass it to the on-error which builds this kind of message from its arguments. We can decompose the message, but it seems to be error-prone if the message format changes. Alternatively, require can be made to return errors in an unformatted way if an optional second argument is provided, but this looks like a lot of changes in the compiler, and we still probably can't control runtime errors coming from Lua itself (correct me if I'm wrong).

Status
REPORTED
Submitter
~andreyorst
Assigned to
No-one
Submitted
5 months ago
Updated
5 months ago
Labels
enhancement