about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
AgeCommit message (Collapse)AuthorFilesLines
2014-09-17 Add some instrumentation for debugging GC leaksEelco Dolstra1-0/+22
2014-09-02 Fix boost::too_many_args errorEelco Dolstra1-1/+1
Fixes #333.
2014-08-20 Use proper quotes everywhereEelco Dolstra1-14/+14
2014-08-13 Fix warning about non-existant -I directoriesEelco Dolstra1-1/+1
2014-06-10 == operator: Ignore string contextEelco Dolstra1-11/+2
There really is no case I can think of where taking the context into account is useful. Mostly it's just very inconvenient.
2014-05-26 Remove ExprBuiltinEelco Dolstra1-11/+0
It's slower than ExprVar since it doesn't compute a static displacement. Since we're not using the throw primop in the implementation of <...> anymore, it's also not really needed.
2014-05-26 Ensure that -I flags get included in nixPathEelco Dolstra1-4/+3
Also fixes #261.
2014-05-15 Provide a more useful error message when a dynamic attr lookup failsShea Levy1-2/+10
2014-04-04 Show position info in attribute selection errorsEelco Dolstra1-7/+7
2014-04-04 Show position info in Boolean operationsEelco Dolstra1-7/+17
2014-04-04 Show position info in string concatenation / addition errorsEelco Dolstra1-12/+27
2014-04-04 forceString: Show position infoEelco Dolstra1-9/+24
2014-04-04 forceAttrs: Show position infoEelco Dolstra1-1/+1
2014-04-04 forceList: Show position infoEelco Dolstra1-7/+2
2014-04-04 forceInt: Show position infoEelco Dolstra1-2/+2
2014-04-04 Pass position information to primop callsEelco Dolstra1-3/+3
For example: error: `tail' called on an empty list, at /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix:13:7
2014-04-04 Include position info in function applicationEelco Dolstra1-12/+19
This allows error messages like: error: the anonymous function at `/etc/nixos/configuration.nix:1:1' called without required argument `foo', at `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/lib/modules.nix:77:59'
2014-03-30 boost::shared_ptr -> std::shared_ptrEelco Dolstra1-0/+1
2014-03-10 The expr of AttrNames/DynamicAttrDefs is always an ExprConcatStringsShea Levy1-5/+3
2014-03-10 If a dynamic attribute name evaluates to null, remove it from the setShea Levy1-1/+9
2014-03-05 Revert "Make ifs and asserts tail-recursive"Eelco Dolstra1-10/+4
This reverts commit 273322c7732093a354e86df82cf75d6604b8bce8.
2014-02-27 Correctly detect infinite recursion in function applicationEelco Dolstra1-2/+4
If we're evaluating some application ‘v = f x’, we can't store ‘f’ temporarily in ‘v’, because if ‘f x’ refers to ‘v’, it will get ‘f’ rather than an infinite recursion error. Unfortunately, this breaks the tail call optimisation introduced in c897bac54954373f63511702731fe2cb23c0c98e. Fixes #217.
2014-01-21 Merge branch 'master' into makeEelco Dolstra1-4/+51
Conflicts: src/libexpr/eval.cc
2013-12-31 Don't use any syntactic sugar for dynamic attrsShea Levy1-3/+17
This doesn't change any functionality but moves some behavior out of the parser and into the evaluator in order to simplify the code. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Dynamic attrsShea Levy1-1/+23
This adds new syntax for attribute names: * attrs."${name}" => getAttr name attrs * attrs ? "${name}" => isAttrs attrs && hasAttr attrs name * attrs."${name}" or def => if attrs ? "${name}" then attrs."${name}" else def * { "${name}" = value; } => listToAttrs [{ inherit name value; }] Of course, it's a bit more complicated than that. The attribute chains can be arbitrarily long and contain combinations of static and dynamic parts (e.g. attrs."${foo}".bar."${baz}" or qux), which is relatively straightforward for the getAttrs/hasAttrs cases but is more complex for the listToAttrs case due to rules about duplicate attribute definitions. For attribute sets with dynamic attribute names, duplicate static attributes are detected at parse time while duplicate dynamic attributes are detected when the attribute set is forced. So, for example, { a = null; a.b = null; "${"c"}" = true; } will be a parse-time error, while { a = {}; "${"a"}".b = null; c = true; } will be an eval-time error (technically that case could theoretically be detected at parse time, but the general case would require full evaluation). Moreover, duplicate dynamic attributes are not allowed even in cases where they would be with static attributes ({ a.b.d = true; a.b.c = false; } is legal, but { a."${"b"}".d = true; a."${"b"}".c = false; } is not). This restriction might be relaxed in the future in cases where the static variant would not be an error, but it is not obvious that that is desirable. Finally, recursive attribute sets with dynamic attributes have the static attributes in scope but not the dynamic ones. So rec { a = true; "${"b"}" = a; } is equivalent to { a = true; b = true; } but rec { "${"a"}" = true; b = a; } would be an error or use a from the surrounding scope if it exists. Note that the getAttr, getAttr or default, and hasAttr are all implemented purely in the parser as syntactic sugar, while attribute sets with dynamic attribute names required changes to the AST to be implemented cleanly. This is an alternative solution to and closes #167 Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Add the ExprBuiltin Expr type to the ASTShea Levy1-0/+11
Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-23 Drop the dependency on libgc in libmainEelco Dolstra1-0/+17
Instead, libexpr now depends on libgc. This means commands like nix-store that don't do any evaluation no longer require libgc.
2013-11-23 Initialise Boehm GC only onceEelco Dolstra1-2/+2
2013-11-19 Add a toJSON primopEelco Dolstra1-20/+23
2013-11-18 Add a primop unsafeGetAttrPos to return the position of an attributeEelco Dolstra1-5/+14
2013-11-18 Add a symbol __curPos that expands to the current source locationEelco Dolstra1-0/+13
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
2013-11-12 Make function calls show up in stack traces againEelco Dolstra1-20/+28
Note that adding --show-trace prevents functions calls from being tail-recursive, so an expression that evaluates without --show-trace may fail with a stack overflow if --show-trace is given.
2013-11-12 Make function calls tail-recursiveEelco Dolstra1-38/+60
2013-11-12 Make ifs and asserts tail-recursiveEelco Dolstra1-4/+10
The local Value object prevented g++ from making a tail call. Not clear why. In any case, not using a temporary makes g++ do the tail call.
2013-11-12 Get rid of an intermediary on the stackEelco Dolstra1-9/+13
2013-10-28 Slightly optimize listToAttrsEelco Dolstra1-0/+1
2013-10-24 Rename "attribute sets" to "sets"Eelco Dolstra1-13/+10
We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose.
2013-10-24 Remove unnecessary call to forceStringNoCtxEelco Dolstra1-1/+1
2013-10-24 Don't require NIX_SHOW_STATS for NIX_COUNT_CALLSEelco Dolstra1-0/+1
2013-10-23 Memoize evalFile() lookups under both the original and resolved nameEelco Dolstra1-4/+9
Previously we only used the resolved name, causing repeated resolution (e.g. /dir to /dir/default.nix).
2013-10-17 Don't show <nix/derivation.nix> in stack tracesEelco Dolstra1-1/+1
Messages like while evaluating the attribute `outPath' at `/nix/store/212ngf4ph63mp6p1np2bapkfikpakfv7-nix-1.6/share/nix/corepkgs/derivation.nix:18:9': are redundant, because Nix already shows that it's evaluating a derivation: while instantiating the derivation named `firefox-24.0' at `/home/eelco/Dev/nixpkgs/pkgs/applications/networking/browsers/firefox/default.nix:131:5': while evaluating the derivation attribute `nativeBuildInputs' at `/home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/default.nix:76:17':
2013-10-17 Revert the behaviour of antiquoted paths to pre-Nix 1.6Eelco Dolstra1-4/+4
Commit 159e621d1a9c4391b53f3d822109c36931934698 accidentally changed the behaviour of antiquoted paths, e.g. "${/foo}/bar" used to evaluate to "/nix/store/<hash>-foo/bar" (where /foo gets copied to the store), but in Nix 1.6 it evaluates to "/foo/bar". This is inconsistent, since " ${/foo}/bar" evaluates to " /nix/store/<hash>-foo/bar". So revert to the old behaviour.
2013-10-08 printStats(): Print the size of the symbol table in bytesEelco Dolstra1-0/+1
2013-10-08 Deduplicate filenames in PosEelco Dolstra1-1/+0
This saves ~4 MiB of RAM for NixOS system instantiation, and ~18 MiB for "nix-env -qa".
2013-10-08 Treat undefined variable errors consistentlyEelco Dolstra1-1/+6
Previously, a undefined variable inside a "with" caused an EvalError (which can be caught), while outside, it caused a ParseError (which cannot be caught). Now both cause an UndefinedVarError (which cannot be caught).
2013-10-08 Show the exact position of undefined variablesEelco Dolstra1-1/+1
In particular, undefined variable errors in a "with" previously didn't show *any* position information, so this should help a lot in those cases.
2013-10-08 Remove some unused functionsEelco Dolstra1-15/+0
2013-10-08 Merge VarRef into ExprVarEelco Dolstra1-3/+3
2013-10-07 Don't show calls to primops in stack tracesEelco Dolstra1-6/+1
Since they don't have location information, they just give you crap like: while evaluating the builtin function `getAttr': while evaluating the builtin function `derivationStrict': ...
2013-10-02 Fix segfault in nix-repl / hydra-eval-jobsEelco Dolstra1-3/+3
If a "with" attribute set fails to evaluate, we have to make sure its Env record remains unchanged. Otherwise, repeated evaluation gives a segfault: nix-repl> :a with 0; { a = x; b = x; } Added 2 variables. nix-repl> a error: value is an integer while an attribute set was expected nix-repl> b Segmentation fault