Closed jrfondren closed 9 months ago
This is not a bug, while compile time errors can traceback the origin of the error, runtime errors cannot. Runtime asserts and checks will only show the line where the error happened.
There is no good cross platform and lightweight way to perform tracebacks at runtime, the best you can do is to use --sanitize
(available only in some systems) so it gives a C traceback of the error. Luckily the C function names are not that hard to understand, and even the C code is not hard to follow when debugging nasty bugs.
I see this as a possible enhancement for the future, that is, to have nice tracebacks messages in case of runtime errors, showing Nelua code, not C code. But it's not that simple to do, and the cross platform way would pollute the C codegen with frame tracing everywhere and also hit performance, I would have to introduce a debug build.
Code example
Which has this output:
Expected behavior
Output similar to the following's:
which is:
NB.
s[500]
has the first output, rather than this.Workaround
Running with
-S
gives more information, if only of C line numbers:Environment
x86_64 linux Nelua 0.2.0-dev Build number: 1609 Git date: 2023-11-15 18:57:47 -0300 Git hash: 19917edbf61fac431256f14682c331d8af1d9f34 Semantic version: 0.2.0-dev.1609+19917edb Copyright (C) 2019-2023 Eduardo Bart (https://nelua.io/)