Commit Graph

11 Commits

Author SHA1 Message Date
Qi Xiao
fef5049716 pkg/eval: Simplify how exception tracebacks are written.
*Exception.Show used to work differently when the traceback contains one frame
vs more frames. Harmonize how they work, and consistent with how parse errors
and compilation errors are shown.
2024-01-16 12:50:59 +00:00
Qi Xiao
5775c8b3ed pkg/diag: Rework API and presentation of Context and Error.
- Change Context to export all its fields.

- Include end position in Context, and include it in Show.

- Remove the Type field from Error, and express it using an ErrorTag type
  parameter instead.

- Make {Pack Unpack}CognateErrors type-safe with the new ErrorTag mechanism, and
  rename them to just {Pack Unpack}Errors.
2024-01-16 11:04:52 +00:00
Qi Xiao
78862465a4 pkg/diag: Include line:col of start position in Error and Show methods.
The Error methods used to show the start and end indices, while the Show methods
used to show line ranges.

Showing line:col of the start position seems to be pretty standard; both Go and
Rust do that.

I tried including the line:col of the end position too, but can't find a good
enough format.
2022-12-08 19:07:18 +00:00
Qi Xiao
7e6bd950b1 pkg/diag: Increase test coverage. 2022-11-30 12:57:02 +00:00
Qi Xiao
9cd90c49bb Minor fixup for #1274. 2021-05-02 00:22:28 +01:00
Kurtis Rader
1e0885310e Include name in error msg setting a readonly var
When attempting to update a read-only var return an error struct rather
than a simple string (i.e., a Go `error` type).  This makes it possible
to include the var name in the error message.  This builds on commit
a33ecb2d that highlights the offending var name in the stack trace but
does not include the var name in the error message. With this change the
error message includes the offending var name.

Related #255
2021-03-26 18:38:22 -07:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
3037f6c8bf pkg/util: Move the wcwidth utilities to a new package, and add more tests.
This addresses #944.
2020-04-06 12:00:01 +01:00
Qi Xiao
c05f11d3dc [cleanup] pkg/diag: PPrint -> Show. 2020-03-31 00:27:08 +01:00
Qi Xiao
9bebf49b40 pkg/diag: Let NewContext accept a Ranging. 2020-03-28 22:12:42 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00