aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-03-17builtins.nixVersion: return fixed fake versionJade Lovelace
This builtin is only going to cause us problems because we are not Nix, so let's just falsify being in the 2.18 series, since that is the closest target that has any meaning. In future we might want to have a better feature detection mechanism, for when we actually add stuff to some builtin's attr set argument. But builtins.nixVersion is just going to be hopelessly broken and it should be stubbed out. Fixes https://git.lix.systems/lix-project/lix/issues/144 Change-Id: Id7390b32a29c6147f2977737d81846320de5d67e
2024-03-16diagnose duplicated attrs at correct patheldritch horrors
diagnose attr duplication at the path the duplication was detected, not at the path the current attribute wanted to place. doing the latter is only correct if a leaf attribute was duplicated, not if an attrpath was set to a non-attrset in one binding and a (potentially implied) attrset in another binding. fixes #124 Change-Id: Ic4aa9cc12a9874d4e7897c6f64408f10aa36fc82
2024-03-15Fix `gc-small-vector.hh` includesRebecca Turner
Change-Id: I4abc19029fb62712582761d4fc1895156b68803d
2024-03-15Allow dlopen of plugins to failJade Lovelace
It happens with some frequency that plugins that might be unimportant to the evaluation at hand mismatch with the nix version, leading to spurious load failures. Let's make these non fatal. Change-Id: Iba10e951d171725ccf1a121bcd9be1e1d6ad69eb
2024-03-14libexpr: fix elided value counting in printereldritch horrors
using the total-attrs-printed and total-list-items-printed counters to calculate how many attrs were elided only works properly if no nesting is involved. once things do nest the global counter can exceed the size of the currently printed object, leading to unsigned wrapping and great overestimation of elided counts. counting locally in addition to global counts fixes this. these are functional tests because creating these objects requires the evaluator to not be a huge amount of code, and we also want defaults to be tested for cli usage. fixes #14 Change-Id: Icb9a0cb21b2f4bacbc5e9dcdd8c0b9055b4088a7
2024-03-11add automated usage mode to the replJade Lovelace
This is definitely not a stable thing, but it does feel slightly crimes to put it as an experimental feature. Shrug, up for bikeshedding. Change-Id: I6ef176e3dee6fb1cac9c0a7a60d553a2c63ea728
2024-03-11Merge "refactor: repl prompts are now the job of the interacter" into mainjade
2024-03-11Merge "refactor: move readline stuff into its own file" into mainjade
2024-03-11Merge "finally.hh: delete copy constructor which is a bad idea" into mainjade
2024-03-11Merge "Add box_ptr: nonnull unique_ptr with value semantics" into mainjade
2024-03-11Merge "util.hh: split out signals stuff" into mainjade
2024-03-11refactor: repl prompts are now the job of the interacterJade Lovelace
Change-Id: I17c2873dfbbff303cdbdc7a8903deb8409ce3026
2024-03-11refactor: move readline stuff into its own fileJade Lovelace
This is in direct preparation for an automation mode of nix repl. Change-Id: I26e6ca88ef1c48aab11a2d1e939ff769f1770caa
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