Some more housekeeping. Destroys nothing, but makes some things easier. (0.37.3)
This commit is contained in:
parent
ebae80cf44
commit
2927f88340
8 changed files with 165 additions and 196 deletions
42
examples/error/repl_on_error.fun
Executable file
42
examples/error/repl_on_error.fun
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* 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>
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue