Replies: 2 comments 2 replies
-
Just kicking around ideas... If the existing I may have looked briefly into making built-ins able to retrieve more runtime information, but it's been a long while, so I don't recall how hard or easy this might be right now. |
Beta Was this translation helpful? Give feedback.
-
Another idea is to only rely on source code references in stack traces, something that lots of languages rely on. So that this: assert(1 == 2) Turns into this: $ risor example.risor
assertion failed
--> example.risor
|
1 | assert(1 == 2)
| ^ here One problem I have with this approach in a lot of other languages is when this stack trace is color highlighted to more than the "assertion failed" message you provided. As a result, your eye goes first to look at the assert string format argument instead of the rendered/formatted string output. For example: var my_var = 123
assert(my_var == 456, 'got {my_var}') Turns into this: $ risor example.risor
assertion failed: got 123
--> example.risor
|
3 | assert(my_var == 456, 'got {my_var}')
| ^ here The example source code view I have here gives more focus on the source code than the error message itself. To see what the actual value of So with an approach like this, the source code preview should be something like "bright black" (in ANSI basic terminal color terms) to not capture your eye too much. |
Beta Was this translation helpful? Give feedback.
-
What if
assert
was a statement built into the language?Then when running something like this:
The error could be:
Idea would be that the assert would print the raw source code of what was in the first argument position. So something like a function call would not suddenly show the return value:
So the error should be:
Beta Was this translation helpful? Give feedback.
All reactions