lix/src/libexpr
Rebecca Turner 9e7e927837 Print top-level errors normally in nix repl
Previously, errors while printing values in `nix repl` would be printed
in `«error: ...»` brackets rather than displayed normally:

```
nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler
«error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate.»
```

Now, errors will be displayed normally if they're emitted at the
top-level of an expression:

```
nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler
error:
       … in the condition of the assert statement
         at /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/lib/customisation.nix:268:17:
          267|     in commonAttrs // {
          268|       drvPath = assert condition; drv.drvPath;
             |                 ^
          269|       outPath = assert condition; drv.outPath;

       … in the left operand of the OR (||) operator
         at /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/passthrufun.nix:28:45:
           27|         if lib.isDerivation value then
           28|           lib.extendDerivation (valid value || throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.") {} value
             |                                             ^
           29|         else

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate.
```

Errors emitted in nested structures (like e.g. when printing `nixpkgs`)
will still be printed in brackets.

Change-Id: I25aeddf08c017582718cb9772a677bf51b9fc2ad
2024-04-09 08:34:40 -07:00
..
flake Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
primops Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
value Merge pull request #9925 from 9999years/fmt-cleanup 2024-03-09 07:00:13 -07:00
attr-path.cc libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00
attr-path.hh Merge remote-tracking branch 'upstream/master' into source-path 2023-04-17 11:41:50 +02:00
attr-set.cc Don't pass Symbol by reference 2022-04-26 13:25:17 +02:00
attr-set.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
eval-cache.cc always re-eval cached failures 2024-04-06 04:35:25 +00:00
eval-cache.hh always re-eval cached failures 2024-04-06 04:35:25 +00:00
eval-error.cc always re-eval cached failures 2024-04-06 04:35:25 +00:00
eval-error.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
eval-inline.hh libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00
eval-settings.cc Delete hasPrefix and hasSuffix from the codebase 2024-03-17 20:17:19 -07:00
eval-settings.hh Merge "Add repl-overlays" into main 2024-04-09 05:29:48 +00:00
eval.cc Merge pull request #9920 from 9999years/forbid-nested-debuggers 2024-03-31 17:28:25 +00:00
eval.hh Merge pull request #9920 from 9999years/forbid-nested-debuggers 2024-03-31 17:28:25 +00:00
fetchurl.nix Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
function-trace.cc Revert the enum struct change 2020-06-18 22:11:26 +00:00
function-trace.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
gc-small-vector.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
get-drvs.cc remove getDerivations deduplication 2024-03-10 03:18:32 -06:00
get-drvs.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
imported-drv-to-derivation.nix Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
json-to-value.cc libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00
json-to-value.hh libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00
lexer.l use byte indexed locations for PosIdx 2024-03-18 16:12:46 +01:00
local.mk Merge pull request #9465 from obsidiansystems/build-dir 2024-03-04 07:11:25 +01:00
meson.build meson: add missing explicit dependency on nlohmann_json 2024-03-29 14:16:58 -04:00
nix-expr.pc.in Fix building with GCC 9 2023-02-10 18:38:57 +01:00
nixexpr.cc Move escapeString to its own file 2024-03-29 16:26:29 -07:00
nixexpr.hh Document ExprLambda fields 2024-03-29 18:29:59 -07:00
parser-state.hh use byte indexed locations for PosIdx 2024-03-18 16:12:46 +01:00
parser.y use byte indexed locations for PosIdx 2024-03-18 16:12:46 +01:00
paths.cc Merge pull request #9172 from tfc/bad-moves 2024-03-04 04:41:52 +01:00
pos-idx.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
pos-table.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
primops.cc avoid markdown which the repl's :doc cannot handle 2024-04-06 13:14:14 +00:00
primops.hh use byte indexed locations for PosIdx 2024-03-18 16:12:46 +01:00
print-ambiguous.cc Move escapeString to its own file 2024-03-29 16:26:29 -07:00
print-ambiguous.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
print-options.hh Print top-level errors normally in nix repl 2024-04-09 08:34:40 -07:00
print.cc Print top-level errors normally in nix repl 2024-04-09 08:34:40 -07:00
print.hh Move escapeString to its own file 2024-03-29 16:26:29 -07:00
repl-exit-status.hh pragma once and ///@file everything missing it 2024-04-08 15:40:12 -07:00
search-path.cc src/libexpr/search-path.cc: avoid out-of-bounds read on string_view 2023-08-14 22:07:37 +01:00
search-path.hh Clean up SearchPath 2023-07-09 23:22:22 -04:00
symbol-table.hh Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
value-to-json.cc util.hh: split out signals stuff 2024-03-11 00:52:09 -07:00
value-to-json.hh Use std::set<StringContextElem> not PathSet for string contexts 2023-04-21 01:05:49 -04:00
value-to-xml.cc util.hh: split out signals stuff 2024-03-11 00:52:09 -07:00
value-to-xml.hh Use std::set<StringContextElem> not PathSet for string contexts 2023-04-21 01:05:49 -04:00
value.hh libexpr: Support structured error classes 2024-03-09 04:47:05 -07:00