[Nix-dev] Need a better error report on the location of undefined variables.

Nicolas Pierron nicolas.b.pierron at gmail.com
Tue May 26 11:23:24 CEST 2009


Hi list,

Currently, when you add a with statement at the top of your nix
expression, this means that you will spend much more time at finding
misspelled variables.  The following error message was caused by an
extra argument at the inside a attribute called merge declared line
182 of /trace/nixpkgs/pkgs/lib/options.nix.

error: while evaluating the function at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 11:
while evaluating the attribute `<let-body>' at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 35:
while evaluating the attribute `pkgs' at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 85:
while evaluating the attribute `pkgsOverriden' at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 84:
while evaluating the function at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 89:
while evaluating the attribute `__overrides' at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 81:
while evaluating the function at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 69:
while evaluating the attribute `lib' at
`/trace/nixpkgs/pkgs/top-level/all-packages.nix', line 37:
while evaluating the file `/trace/nixpkgs/pkgs/lib':
while evaluating the attribute `<let-body>' at
`/trace/nixpkgs/pkgs/lib/default.nix', line 1:
while evaluating the attribute `options' at
`/trace/nixpkgs/pkgs/lib/default.nix', line 8:
while evaluating the file `/trace/nixpkgs/pkgs/lib/options.nix':
while evaluating the attribute `<let-body>' at
`/trace/nixpkgs/pkgs/lib/options.nix', line 3:
while evaluating the `with' body at
`/trace/nixpkgs/pkgs/lib/options.nix', line 5:
while evaluating the `with' body at
`/trace/nixpkgs/pkgs/lib/options.nix', line 6:
while evaluating the `with' body at
`/trace/nixpkgs/pkgs/lib/options.nix', line 7:
while evaluating the `with' body at
`/trace/nixpkgs/pkgs/lib/options.nix', line 8:
while evaluating the `with' body at
`/trace/nixpkgs/pkgs/lib/options.nix', line 9:
undefined variable `list'

Unfortunately the current implementation does not report where is
located the undefined variable.  I know that identifier do not have a
location index, but attribute does and most of the time the undefined
variables are included inside attribute values.

Currently, I am against the with statement because of such error
messages, and I prefer to declare all my variables with a "let inherit
in" statement where all imported variables are clearly shown.

with { inherit (set) var1 var2; };

is IMO worst than

let inherit (set) var1 var2; in

because it add an extra line inside the error log which does not help
as opposed to the "let inherit in" statement which does not not show
up.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list