Debugger is missing locals (or an env at all) from lambdas sometimes #783

Open
opened 2025-03-31 20:12:36 +00:00 by jade · 0 comments
Owner

The debugger is missing the lambda local environment in the following case:

let
  selected = [ { a = builtins.break 2; } ];
  isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
in
  isNotSelected { a = 4; }

Output:

$ nix eval -f test.nix --debugger --ignore-try
info: breakpoint reached

Added isNotSelected.
Added selected.
Lix 2.93.0-dev-pre20250324-4181796 debugger
Type :? for help.
nix-repl> :bt

0: error: breakpoint reached
«none»:0
1: while calling a function
/Users/jade/foo/test.nix:2:22

     1| let
     2|   selected = [ { a = builtins.break 2; } ];
      |                      ^
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;

2: while evaluating the attribute 'a'
/Users/jade/foo/test.nix:3:62

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                                                              ^
     4| in

3: while calling anonymous lambda
/Users/jade/foo/test.nix:3:40

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                                        ^
     4| in

4: while calling a function
/Users/jade/foo/test.nix:3:26

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                          ^
     4| in

5: while calling 'isNotSelected'
/Users/jade/foo/test.nix:3:19

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                   ^
     4| in

6: while calling a function
/Users/jade/foo/test.nix:5:3

     4| in
     5|   isNotSelected { a = 4; }
      |   ^
     6| 

7: while evaluating a 'let' expression
/Users/jade/foo/test.nix:1:1

     1| let
      | ^
     2|   selected = [ { a = builtins.break 2; } ];

8: while evaluating the file '/Users/jade/foo/test.nix':
/Users/jade/foo/test.nix:1:1

     1| let
      | ^
     2|   selected = [ { a = builtins.break 2; } ];

nix-repl> :st 3

3: while calling anonymous lambda
/Users/jade/foo/test.nix:3:40

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                                        ^
     4| in


nix-repl> :env

nix-repl>

Expected result: :env lists some stuff and there is anything at all in the environment (including builtins).
For example, what we get in :st 2:

nix-repl> :st 2

2: while evaluating the attribute 'a'
/Users/jade/dev/mwb/test.nix:3:62

     2|   selected = [ { a = builtins.break 2; } ];
     3|   isNotSelected = input: builtins.all (p: input.a or null != p.a) selected;
      |                                                              ^
     4| in

Env level 0
static: p 

Env level 1
static: input 

Env level 2
static: isNotSelected selected 

Env level 3
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTre
e fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true 

Added input.
Added isNotSelected.
Added p.
Added selected.

nix-repl> :env
Env level 0
static: p 

Env level 1
static: input 

Env level 2
static: isNotSelected selected 

Env level 3
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTre
e fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true 
The debugger is missing the lambda local environment in the following case: ```nix let selected = [ { a = builtins.break 2; } ]; isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; in isNotSelected { a = 4; } ``` Output: ``` $ nix eval -f test.nix --debugger --ignore-try info: breakpoint reached Added isNotSelected. Added selected. Lix 2.93.0-dev-pre20250324-4181796 debugger Type :? for help. nix-repl> :bt 0: error: breakpoint reached «none»:0 1: while calling a function /Users/jade/foo/test.nix:2:22 1| let 2| selected = [ { a = builtins.break 2; } ]; | ^ 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; 2: while evaluating the attribute 'a' /Users/jade/foo/test.nix:3:62 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in 3: while calling anonymous lambda /Users/jade/foo/test.nix:3:40 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in 4: while calling a function /Users/jade/foo/test.nix:3:26 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in 5: while calling 'isNotSelected' /Users/jade/foo/test.nix:3:19 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in 6: while calling a function /Users/jade/foo/test.nix:5:3 4| in 5| isNotSelected { a = 4; } | ^ 6| 7: while evaluating a 'let' expression /Users/jade/foo/test.nix:1:1 1| let | ^ 2| selected = [ { a = builtins.break 2; } ]; 8: while evaluating the file '/Users/jade/foo/test.nix': /Users/jade/foo/test.nix:1:1 1| let | ^ 2| selected = [ { a = builtins.break 2; } ]; nix-repl> :st 3 3: while calling anonymous lambda /Users/jade/foo/test.nix:3:40 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in nix-repl> :env nix-repl> ``` Expected result: `:env` lists some stuff and there is anything at all in the environment (including builtins). For example, what we get in `:st 2`: ``` nix-repl> :st 2 2: while evaluating the attribute 'a' /Users/jade/dev/mwb/test.nix:3:62 2| selected = [ { a = builtins.break 2; } ]; 3| isNotSelected = input: builtins.all (p: input.a or null != p.a) selected; | ^ 4| in Env level 0 static: p Env level 1 static: input Env level 2 static: isNotSelected selected Env level 3 abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTre e fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true Added input. Added isNotSelected. Added p. Added selected. nix-repl> :env Env level 0 static: p Env level 1 static: input Env level 2 static: isNotSelected selected Env level 3 abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTre e fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#783
No description provided.