Closed amano-kenji closed 9 months ago
For future readers, see this comment for example invocations along with output and some explanation.
So the issue here is there is an explicit macro expansion here inside the if-let macro that doesn't preserve the source location information. We can fix this issue by making slight modifications to macex1
which does the explicit macro expansion. This should also fix source mapping information for any macros that explicitly expand sub forms manually, instead of the usual case of letting the be.
I tried 7a2868c with the sample code.
Both invocations produced the expected output here:
$ janet recurse.janet true
alive: print stack for true branch
in debug/stacktrace [src/core/debug.c] on line 388
in recurse [recurse.janet] (tailcall) on line 6, column 7
...
$ janet recurse.janet false
alive: print stack for false branch
in debug/stacktrace [src/core/debug.c] on line 388
in recurse [recurse.janet] (tailcall) on line 10, column 7
...
@amano-kenji Does it work for you?
I tested the latest commit, and the issue seems fixed.
With this,
debug/stacktrace
in the false branch doesn't report its own line in the call stack, but the line whereif-let
resides.debug/stacktrace
in the true branch reports its own line in the call stack.