1
0
Fork 0
forked from fun/fun

Jump into REPL when executing with --repl-on-error and an error occurs, when the REPL is builtin you will have access to the full stack then. (0.25.0)

This commit is contained in:
Johannes Findeisen 2025-10-06 04:10:36 +02:00
commit c71857a068
9 changed files with 309 additions and 7 deletions

View file

@ -0,0 +1,42 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the Apache-2.0 license.
* https://opensource.org/license/apache-2-0
*
* Added: 2025-10-06
*/
// Demonstration of --repl-on-error debugging.
// Run: fun --repl-on-error examples/repl_on_error.fun
// When the runtime error occurs, the REPL opens. Try commands:
// :backtrace
// :stack
// :locals
//
// This script triggers an index-out-of-range error inside a nested call.
fun inner()
a = [1, 2, 3]
// Out-of-range access to cause a runtime error:
print(a[10])
fun outer()
inner()
outer()
/* Expected output (ruuning with --repl-on-error you will end up in the REPL
* with full stack access; :backtrace, :stack and :locals):
Runtime error: index out of range
(at ./examples/repl_on_error.fun:12 in inner, op INDEX_GET @ip 9)
Entering REPL due to runtime error (code 1)
(at ./examples/repl_on_error.fun:12 in inner, op INDEX_GET @ip 9)
Fun 0.25.0 REPL
Type :help for commands. Submit an empty line to run.
fun>
*/