Files
lix/tests/functional/repl_characterization/data/stacktrace_invalid_arg.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

74 lines
1.9 KiB
Plaintext

@args --debugger
nix-repl> throw "(forever?????????)"
error: (forever?????????)
argument-less :st works fine
nix-repl> :st
0: error: (forever?????????)
«string»:1:1
1| throw "(forever?????????)"
| ^
Env level 0
static:
Env level 1
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
a non-numeric strings produces an error
nix-repl> :st chat
error: argument 'chat' is not a valid integer
nix-repl> :st bedroom community
error: argument 'bedroom community' is not a valid integer
...even when they start with a digit
nix-repl> :st 6up
error: argument '6up' is not a valid integer
...or when they're floats
nix-repl> :st 4.50
error: argument '4.50' is not a valid integer
an integer outside the range produces an error
nix-repl> :st 23571113171923
error: argument '23571113171923' is not a valid integer
argument-less :st is still at the same index after errors
nix-repl> :st 1
1: while calling a function
«string»:1:1
1| throw "(forever?????????)"
| ^
Env level 0
static:
Env level 1
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 foo
error: argument 'foo' is not a valid integer
nix-repl> :st
1: while calling a function
«string»:1:1
1| throw "(forever?????????)"
| ^
Env level 0
static:
Env level 1
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: (forever?????????)