aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-03-11finally.hh: delete copy constructor which is a bad ideaJade Lovelace
Change-Id: I6d0b5736893c44bddc6f5789b452b434f8671b9b
2024-03-11Add box_ptr: nonnull unique_ptr with value semanticsJade Lovelace
This solves the problem of collections of boxed subclasses with virtual dispatch, which should still be treated as values, since the indirection is only there due to the virtual dispatch. Change-Id: I368daedd3f31298e99c6e56a15606337a55494c6
2024-03-11util.hh: split out signals stuffJade Lovelace
Copies part of the changes of ac89bb064aeea85a62b82a6daf0ecca7190a28b7 Change-Id: I9ce601875cd6d4db5eb1132d7835c5bab9f126d8
2024-03-10Merge "Print derivation paths in `nix eval`" into mainjade
2024-03-10add doc comment justifying ExprInheritFromeldritch horrors
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> (cherry picked from commit f24e445bc024cfd3c26be5f061280af549321c22) Change-Id: I7acda5d5c34c0914a78adc2385d32782c4c275cd
2024-03-10remove ExprAttrs::AttrDef::inheritedeldritch horrors
it's no longer widely used and has a rather confusing meaning now that inherit-from is handled very differently. (cherry picked from commit 1cd87b7042d14aae1fafa47b1c28db4c5bd20de7) Change-Id: I90bbebddf06762960d8ca4f621cf042ce8ae83f9
2024-03-10evaluate inherit (from) exprs only once per directiveeldritch horrors
desugaring inherit-from to syntactic duplication of the source expr also duplicates side effects of the source expr (such as trace calls) and expensive computations (such as derivationStrict). (cherry picked from commit cefd0302b55b3360dbca59cfcb4bf6a750d6cdcf) Change-Id: Iff519f991adef2e51683ba2c552d37a3df7a179e
2024-03-10remove getDerivations deduplicationeldritch horrors
deduplication does not currently work fully, showing derivations multiple times if they have different underlying values. this can happen by selecting the same derivation twice for two different attributes of a set, using inherit-from (which reduces to the previous), importing nixpkgs twice, or any other number of things. since users already have to deal with duplicates for this reason it won't hurt to add *more* duplicates. the alternative would be to deduplicate fully, which would drop derivations that are currently returned and those pose a regression risk. Change-Id: I64b397351237e10375d270f1bddecb71f62aa131
2024-03-10group inherit by source during Expr::showeldritch horrors
for plain inherits this is really just a stylistic choice, but for inherit-from it actually fixes an exponential size increase problem during expr printing (as may happen during assertion failure reporting, on during duplicate attr detection in the parser) (cherry picked from commit ecf8b12d60ad2929f9998666cf0966475b91e291) Change-Id: Ie55f0cb01a37e766414c31f8d40f51c2c7d106b0
2024-03-10use the same bindings print for ExprAttrs and ExprLeteldritch horrors
this also has the effect of sorting let bindings lexicographically rather than by symbol creation order as was previously done, giving a better canonicalization in the process. (cherry picked from commit 6c08fba533ef31cad2bdc03ba72ecf58dc8ee5a0) Change-Id: Ia887f629305645bb8a165fbbc0d32e620912595a
2024-03-10add ExprAttrs::AttrDef::chooseByKindeldritch horrors
in place of inherited() — not quite useful yet since we don't distinguish plain and inheritFrom attr kinds so far. (cherry picked from commit 1f542adb3e18e7078e6a589182a53a47d971748a) Change-Id: If948c9d43e875de18f213a73a06a36f7c335b536
2024-03-10preserve information about whether/how an attribute was inheritedeldritch horrors
(cherry picked from commit c66ee57edc6cac3571bfbf77d0c0ea4d25b4e805) Change-Id: Ie8606a8b2f5946c87dd4d16b7b46203e199a4cc1
2024-03-09Merge pull request #10066 from 9999years/print-all-frameseldritch horrors
Do not skip any stack frames when `--show-trace` is given (cherry picked from commit 0b47783d0a879875d558f0b56e49584f25ceb2d0) Change-Id: Ia0f18266dbcf97543110110c655c219c7a3e3270
2024-03-09Merge pull request #9914 from 9999years/debugger-on-traceeldritch horrors
Enter debugger on `builtins.trace` with an option (cherry picked from commit 774e7ca5847ebc392eac2a124a8f12b24da4f65a) Change-Id: If01e2110b3a128e639b05143227e365227d149f1
2024-03-09Rename `ProcessLineResult` variantseldritch horrors
(cherry picked from commit 8e71883e3f59100479e96aa1883ef52dbaa03fd3) Change-Id: If7d8b75eaec623dac106ce2363fa148af37d150c
2024-03-09`:quit` in the debugger should quit the whole programeldritch horrors
(cherry picked from commit 2a8fe9a93837733e9dd9ed5c078734a35b203e14) Change-Id: I71dadfef6b24d9272b206e9e2c408040559d8a1c
2024-03-09Extract `printSpace` helpereldritch horrors
(cherry picked from commit 403c90ddf58a3f16a44dfe1f20004b6baa4e5ce2) Change-Id: I53c9824e6b1c4c619b4dfd8346d39e5289d92265
2024-03-09`prettyPrint` -> `shouldPrettyPrint`eldritch horrors
(cherry picked from commit 1c5f5d4291df7bf80806e57c75d2ec67bced8616) Change-Id: I7a517490e7baa5cef00716f6d6cfcbcbcdde11bf
2024-03-09Add assertion for decreasing the indenteldritch horrors
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> (cherry picked from commit a27651908fc1b5ef73a81e46434a408c5868fa7b) Change-Id: I2ec78e234c1c6e982f7b05f81d8b8356daf6c274
2024-03-09Pretty-print values in the REPLeldritch horrors
Pretty-print values in the REPL by printing each item in a list or attrset on a separate line. When possible, single-item lists and attrsets are printed on one line, as long as they don't contain a nested list, attrset, or thunk. Before: ``` { attrs = { a = { b = { c = { }; }; }; }; list = [ 1 ]; list' = [ 1 2 3 ]; } ``` After: ``` { attrs = { a = { b = { c = { }; }; }; }; list = [ 1 ]; list' = [ 1 2 3 ]; } ``` (cherry picked from commit c0a15fb7d03dfb8f53bc6726c414bc88aa362592) Change-Id: Ia2b41849165a5ddb63f7a8c272a2476b3e4292df
2024-03-09Merge pull request #9925 from 9999years/fmt-cleanupeldritch horrors
Cleanup `fmt.hh` (cherry picked from commit 47a1dbb4b8e7913cbb9b4d604728b912e76e4ca0) Change-Id: Id076a45cb39652f437fe3f8bda10c310a9894777
2024-03-09Add commenteldritch horrors
(cherry picked from commit 9723f533d85133fa3c4d9421a58c7765cb61e733) Change-Id: Idd729febc0bb8c7c8db72a0fae73b680f66767f4
2024-03-09Add commentseldritch horrors
(cherry picked from commit 474fc4078acbe062fcc31ce91c69c8f33bf00d5f) Change-Id: I9f78f7afd8468d0ab676c0f60c4f7d6140128583
2024-03-09Remove `EXCEPTION_NEEDS_THROW_SPEC`eldritch horrors
We're on C++ 20 now, we don't need this (cherry picked from commit faaccecbc82d98288582bdc8ca96991796561371) Change-Id: I172fa336107fd18b1aac2262309682e0d7065d07
2024-03-09Attach positions to errors in `derivationStrict`eldritch horrors
(cherry picked from commit 87dc4bc7d139a7eccb257e71558314a0d99e8d6a) Change-Id: Ib7509cbb1d246ca5aa3607ff860420fe7a754f6a
2024-03-09libexpr: Support structured error classeseldritch horrors
While preparing PRs like #9753, I've had to change error messages in dozens of code paths. It would be nice if instead of EvalError("expected 'boolean' but found '%1%'", showType(v)) we could write TypeError(v, "boolean") or similar. Then, changing the error message could be a mechanical refactor with the compiler pointing out places the constructor needs to be changed, rather than the error-prone process of grepping through the codebase. Structured errors would also help prevent the "same" error from having multiple slightly different messages, and could be a first step towards error codes / an error index. This PR reworks the exception infrastructure in `libexpr` to support exception types with different constructor signatures than `BaseError`. Actually refactoring the exceptions to use structured data will come in a future PR (this one is big enough already, as it has to touch every exception in `libexpr`). The core design is in `eval-error.hh`. Generally, errors like this: state.error("'%s' is not a string", getAttrPathStr()) .debugThrow<TypeError>() are transformed like this: state.error<TypeError>("'%s' is not a string", getAttrPathStr()) .debugThrow() The type annotation has moved from `ErrorBuilder::debugThrow` to `EvalState::error`. (cherry picked from commit c6a89c1a1659b31694c0fbcd21d78a6dd521c732) Change-Id: Iced91ba4e00ca9e801518071fb43798936cbd05a
2024-03-09Move `PodIdx` to `pos-idx.hh` and `PosTable` to `pos-table.hh`eldritch horrors
(cherry picked from commit c62c21e29af20f1c14a59ab37d7a25dd0b70f69e) Change-Id: Id4ea2fc33b0874b2f1f2a32cabcbeb0afa26808f
2024-03-09Merge pull request #9928 from 9999years/error-messages-in-nix-repleldritch horrors
Improve error printing in `nix repl` (cherry picked from commit a8050d9b83052e4b5c52bf2d116381aedec3a93e) Change-Id: I588f92d1dd4c546c98788b71403cc034f5e7129a
2024-03-09Merge pull request #9929 from 9999years/dont-print-values-in-magentaeldritch horrors
Don't print the first bracket in values in magenta in error messages (cherry picked from commit 46a0625a40aef6946a35f92fdacf0e6b4a14414f) Change-Id: I8435565c87db182116140eaeea9df1243e67ea94
2024-03-09Merge pull request #9917 from 9999years/enter-debugger-more-reliablyeldritch horrors
Enter debugger more reliably in `let` expressions and function calls (cherry picked from commit c4ed92fa6f836d3d8eb354a48c37a2f9eeecc3aa) Change-Id: I16d0cad7e898feecd2399723b92ba8df67222fb4
2024-03-09Merge pull request #9927 from 9999years/catch-error-in-value-printereldritch horrors
Catch `Error`, not `BaseError` in `ValuePrinter` BaseError includes Interrupt. We probably don't want the value printer to tell you Ctrl-C was pressed while it was printing. (cherry picked from commit c291d2d8dda38aa88b004e2ed05b28653c07e342) Change-Id: I70b105bfb2f52a8f345ae0281d12f022aa36b14e
2024-03-09Merge pull request #9926 from 9999years/fix-cycle-detection-in-nix-repleldritch horrors
Fix cycle detection in `nix repl` (cherry picked from commit e190c20c3394fd1a5cd9be1afc3f30ab32dcd36b) Change-Id: Ie385e781b9f0b7171ca653bcd53a990bb41f9e4b
2024-03-08Print derivation paths in `nix eval`Rebecca Turner
`nix eval` forces values and prints derivations as attribute sets, so commands that print derivations (e.g. `nix eval nixpkgs#bash`) will infinitely loop and segfault. Printing derivations as `.drv` paths makes `nix eval` complete as expected. Further work is needed, but this is better than a segfault. (cherry picked from commit 4910d74086a85876e093136a0e8ebc547b467af7) Change-Id: I8e1cb39c05db812080759ec183ee7a131760e6ea
2024-03-09Minor formatting tweakseldritch horrors
(cherry picked from commit 365b831e6f290c733da6879dae871dada343a1eb) Change-Id: Ife3d269d2f87d6e3fe8a348995019dfc08ac75eb
2024-03-09Update src/libexpr/eval.cceldritch horrors
Co-authored-by: John Ericson <git@JohnEricson.me> (cherry picked from commit 80b84710b8c676620ed1e8bf8ff3bb1d5bc19b80) Change-Id: I128555f1ae13cf0e202f565ee439f698efe12431
2024-03-09don't repeatedly look up ast internal symbolseldritch horrors
these symbols are used a *lot*, so it makes sense to cache them. this mostly increases clarity of the code (however clear one may wish to call the parser desugaring here), but it also provides a small performance benefit. (cherry picked from commit 09a1128d9e2ff0ae6176784938047350d6f8a782) Change-Id: I73d9f66be4555168e048cb2d542277251580c2d1
2024-03-09decouple parser and EvalStateeldritch horrors
there's no reason the parser itself should be doing semantic analysis like bindVars. split this bit apart (retaining the previous name in EvalState) and have the parser really do *only* parsing, decoupled from EvalState. (cherry picked from commit b596cc9e7960b9256bcd557334d81e9d555be5a2) Change-Id: I481a7623afc783e9d28a6eb4627552cf8a780986
2024-03-09slim down parser.yeldritch horrors
most EvalState and Expr members defined here could be elsewhere, where they'd be easier to maintain (not being embedded in a file with arcane syntax) and *somewhat* more faithfully placed according to the path of the file they're defined in. (cherry picked from commit e1aa585964c3d864ebff0030584f3349a539d615) Change-Id: Ibc704567462bb40f37cda05d8fadd465519db5f5
2024-03-09rename ParserState::{makeCurPos -> at}eldritch horrors
most instances of this being used do not refer to the "current" position, sometimes not even to one reasonably close by. it could also be called `makePos` instead, but `at` seems clear in context. (cherry picked from commit 835a6c7bcfd0b22acc16f31de5fc7bb650d52017) Change-Id: I17cab8a6cc14cac5b64624431957bfcf04140809
2024-03-09move ParseData to own header, rename to ParserStateeldritch horrors
ParserState better describes what this struct really is. the parser really does modify its state (most notably position and symbol tables), so calling it that rather than obliquely "data" (which implies being input only) makes sense. (cherry picked from commit 007605616477f4f0d8a0064c375b1d3cf6188ac5) Change-Id: I92feaec796530e1d4d0f7d4fba924229591cea95
2024-03-09make parser utility functions members of ParseDataeldritch horrors
all of them need access to parser state in some way. make them members to allow this without fussing so much. (cherry picked from commit 1b09b80afac27c67157d4b315c237fa7bb9b8d08) Change-Id: I3145c95666a5617b735eff7cb403c54c0fe86347
2024-03-09simplify parse error reportingeldritch horrors
since nix doesn't use the bison `error` terminal anywhere any invocation of yyerror will immediately cause a failure. since we're *already* leaking tons of memory whatever little bit bison allocates internally doesn't much matter any more, and we'll be replacing the parser soon anyway. coincidentally this now also matches the error behavior of URIs when they are disabled or ~/ paths in pure eval mode, duplicate attr detection etc. (cherry picked from commit e8d9de967fe47a7f9324b0022a2ef50df59f419d) Change-Id: I560c50d11dceddc2d7cf9ed2c6c631a309ce574e
2024-03-09remove ParserFormalseldritch horrors
this is a proper subset of Formals anyway, so let's just use those and avoid the extra allocations and moves. (cherry picked from commit f07388bf985c2440413f398cf93d5f5840d1ec8c) Change-Id: I4508c9c9c918cbaaed649dc753eb86f5cafc7ab6
2024-03-09Merge pull request #9754 from 9999years/print-value-when-coercion-failseldritch horrors
Print the value in `error: cannot coerce` messages (cherry picked from commit 5b7bfd2d6b89d7dd5f54c1ca6c8072358d31a84e) === test taken from 6e8d5983143ae576e3f4b1d2954a5267f2943a49; it was added previously (and not backported because its pr was a mostly-revert), but it's useful to have around. Change-Id: Icbd14b55e3610ce7b774667bf14b82e6dc717982
2024-03-09Merge pull request #9818 from Ma27/print-value-on-function-call-type-erroreldritch horrors
libexpr: print value of what is attempted to be called as function (cherry picked from commit 50e5d7b883042852538371237e32a66bb22f0485) Change-Id: I7cb6290bd8f244e83bfce3b2eed2a4c8b4f16a83
2024-03-09Merge pull request #9753 from 9999years/print-value-on-type-erroreldritch horrors
Print the value in `value is X while a Y is expected` error (cherry picked from commit 5f72a97092da6af28a7d2b2a50d74e9d34fae7e1) Change-Id: Idb4bc903ae59a0f5b6fb3b1da4d47970fe0a6efe
2024-03-09Unify and refactor value printingeldritch horrors
Previously, there were two mostly-identical value printers -- one in `libexpr/eval.cc` (which didn't force values) and one in `libcmd/repl.cc` (which did force values and also printed ANSI color codes). This PR unifies both of these printers into `print.cc` and provides a `PrintOptions` struct for controlling the output, which allows for toggling whether values are forced, whether repeated values are tracked, and whether ANSI color codes are displayed. Additionally, `PrintOptions` allows tuning the maximum number of attributes, list items, and bytes in a string that will be displayed; this makes it ideal for contexts where printing too much output (e.g. all of Nixpkgs) is distracting. (As requested by @roberth in https://github.com/NixOS/nix/pull/9554#issuecomment-1845095735) Please read the tests for example output. Future work: - It would be nice to provide this function as a builtin, perhaps `builtins.toStringDebug` -- a printing function that never fails would be useful when debugging Nix code. - It would be nice to support customizing `PrintOptions` members on the command line, e.g. `--option to-string-max-attrs 1000`. (cherry picked from commit 0fa08b451682fb3311fe58112ff05c4fe5bee3a4, ) === Restore ambiguous value printer for `nix-instantiate` The Nix team has requested that this output format remain unchanged. I've added a warning to the man page explaining that `nix-instantiate --eval` output will not parse correctly in many situations. (cherry picked from commit df84dd4d8dd3fd6381ac2ca3064432ab31a16b79) Change-Id: I7cca6b4b53cd0642f2d49af657d5676a8554c9f8
2024-03-08Unindent `print.hh` declarationseldritch horrors
(cherry picked from commit c9125603a535f82cc9a53f47533f0a3d174e7008) Change-Id: I137a272feee7eb42a017f373cbe4705b0e79b7c1
2024-03-07Merge changes I03bbff94,I778edad1,Iaa80073b,Ib1d58fe4 into maineldritch horrors
* changes: Add release notes Print how many checks are run Print derivation paths Log what `nix flake check` does
2024-03-07Merge pull request #9324 from 9999years/fix-8854-take-2eldritch horrors
Don't attempt to `git add` ignored files (cherry picked from commit 359990dfdc713c80aabd7ea6f7e4528628fbe108) === also added a regression test that isn't upstream to be sure we're actually fixing the bug. Change-Id: I8267a3d0ece9909d8008b7435b90e7b3eee366f6