Improve Error-tracking for Standard Library functions #4679
Replies: 1 comment
-
Can you clarify why the ID of each param matters? I'm not really sure what ID we want there and why, so I suspect we have a lack of articulation of what we want to put in the sourceID. But, I would have though we want the ID of the FnCall expression. Maybe a few use cases (specifically, what is the user doing) would help clarify this for us. In the example of |
Beta Was this translation helpful? Give feedback.
-
This comes out of a conversation on discord
The aim here is to improve trace-ability of errors in stdlib fns.
DvalSource
is used throughout Dark's Runtime to track the source of Incomplete or Errors.It has two values -
SourceID of tlid * id
andSourceNone
(implying we don't have context of the source).The Interpreter currently does a good job of tracking the sources of Dvals.
When a
SourceID
is returned (rather than aSourceNone
), the Editor does a great job of highlighting the source of an Error:The stdlib fns, however, do a poor job of tracking the source of errors - all stdlib functions that return a
DError
currently simply return aDError(SourceNone, "message")
without context of which bit of code (often a fn arg) caused the error. I believe this is a limitation of our standard library functions simply not having the 'id's of each of their params.The definition of
BuiltInFnSig
istype BuiltInFnSig = (ExecutionState * List<Dval>) -> DvalTask
and a standard library function demonstrating this limitation may be found in
Date::parse
:If we updated
BuiltInFnSig
to instead look likeBuiltInFnSig = (ExecutionState * List<id * Dval>) -> DvalTask
then this function definition could instead be
In order to support such, many things would have to change in the Interpreter (just a bunch of
id
-tracking and type changes) - I started going down this path, but got lost. This is me recording my thoughts/progress, to see if this makes sense to pursue after a break. What do you think?Beyond this limitation with Standard Library functions, we also over-use
SourceNone
, or could seemingly choose a "better" (more precise) id to reference - those can be handled separately.Beta Was this translation helpful? Give feedback.
All reactions