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

Eelco Dolstra e.dolstra at tudelft.nl
Tue May 26 13:50:46 CEST 2009


Hi,

Nicolas Pierron wrote:

> 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.

Hm yes, the error message is not very good.  So maybe we should add position
information to variables.  The only downside is that it reduces maximal sharing
/ normal form caching in the evaluator.

BTW, perhaps we should also turn off stack traces by default.  They tend to be
quite long, ideally the final error message should be informative enough by
itself (e.g. in the case of abort calls), and they can always be turned on if
you need them.

> with { inherit (set) var1 var2; };
> 
> is IMO worst than
> 
> let inherit (set) var1 var2; in

Yes, I agree.  However, I prefer

  with pkgs.lib;

over

  let inherit (pkgs.lib) name1 name2 name3 ...;

since the latter is rather tedious and it quickly gets out of date (e.g. I've
seen many of those lines refer to identifiers that aren't actually used in the
expression in question).  The last point might be addressed by having a
evaluator flag to warn for unused variables.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list