Files
lix/tests/functional/repl_characterization/data/stacktrace_oob.test
T
blokykandeldritch horrors 6e1e76f10f libcmd/repl: print error for invalid :st argument
currently, the `:st <n>` command in the debugger will simply silently
fail if the argument cannot be converted to an integer, or if it falls
outside the range of valid stack indices. this isn't too big of problem,
but it can be nicer to tell the user something went wrong, rather than
not give them any output and having them guess (esp. in the second case).

this commit adds two errors, one for each case:

  1. the argument is not actually an integer, or is outside INT_MIN/MAX
     -> "argument '%arg' is not a valid integer"

  2. the argument is an integer outside the range of stack traces
     -> "stack index must be between 0 and %max_frame, but was %arg"

Change-Id: I8109feeede79a9ad3db9ee7dc95d37e7dd19741a
2026-03-18 13:15:13 +00:00

78 lines
1.8 KiB
Plaintext

@args --debugger
nix-repl> let f = _: throw "x_x"; x = f 5; in x
error: x_x
frames from 0 up to 4 work fine
nix-repl> :st 0
0: error: x_x
«string»:1:12
1| let f = _: throw "x_x"; x = f 5; in x
| ^
Env level 0
static: _
Env level 1
static: f x
Env level 2
static:
Env level 3
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
nix-repl> :st 4
4: while evaluating a 'let' expression
«string»:1:1
1| let f = _: throw "x_x"; x = f 5; in x
| ^
Env level 0
static: f x
Env level 1
static:
Env level 2
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
negative frames print an error
nix-repl> :st -1
error: stack index must be between 0 and 4, but was -1
nix-repl> :st -100
error: stack index must be between 0 and 4, but was -100
positives frames out of bounds also print an error
nix-repl> :st 5
error: stack index must be between 0 and 4, but was 5
nix-repl> :st 100
error: stack index must be between 0 and 4, but was 100
argument-less :st is still at the same after oob
nix-repl> :st
4: while evaluating a 'let' expression
«string»:1:1
1| let f = _: throw "x_x"; x = f 5; in x
| ^
Env level 0
static: f x
Env level 1
static:
Env level 2
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
quit
nix-repl> :quit
error: x_x