about summary refs log tree commit diff
path: root/tvix/eval/src/errors.rs (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2022-08-26 r/4492 feat(tvix/eval): implement attribute set access operatorVincent Ambo1-0/+4
Fairly straightforward, handling the optimised representations manually and otherwise delegating to BTreeMap. Note that parsing of raw identifiers is not yet implemented. Encountering an identifier node usually means that there is locals access going on, so we need a special case for compiling a node in such a way that an identifier's literal value ends up on the stack. Change-Id: I13fbab7ac657b17ef3f4c5859fe737c321890c8a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6158 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-26 r/4491 fix(tvix/eval): add operation to assert boolean typeVincent Ambo4-0/+24
This operation is required because both sides of the logical operators are strictly evaluated by Nix, even if the resulting value is not used further. For example, in our implementation of `&&`, if the left-hand side is `true`, then the result of the expression is simply the right-hand side value. This value must be asserted to be a boolean for the semantics of the language to work correctly. Change-Id: I34f5364f2a444753fa1d8b0a1a2b2d9cdf7c6700 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6157 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-25 r/4490 fix: reflect renames of Nix configuration optionssterni5-28/+24
Change-Id: I7e28ac3d71acd7d99a1d3ef97bef9422097e4abf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6154 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-08-25 r/4489 feat(tvix/eval): Add initial benchmarking infrastructureGriffin Smith3-6/+574
Bootstrap some (initially very simple, mostly proof-of-concept) benchmarking infrastructure using Criterion, using the newly-exposed lib from tvix-eval. Change-Id: I4bb93c142ba8d018d7e67e58ac8907a0429398a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6156 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: grfn <grfn@gws.fyi>
2022-08-25 r/4488 feat(tvix/eval): Expose interpret + related types from libGriffin Smith2-12/+15
Add a new `lib.rs` to tvix/eval, which `pub use`s the `interpret` function, and all types mentioned in its return type, and then uses *this* instead of direct `mod` statements in the `main.rs` to implement the entrypoints to the interpreter. This is in preparation for calling these functions from integrated benchmarking infrastructure using Criterion, though other things (like integration tests) might want to do that as well. Change-Id: I7b585134a96b1c56a2ac64d2036b0e51d321bd27 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6155 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: grfn <grfn@gws.fyi>
2022-08-25 r/4487 feat(tvix/compiler): implement `->` (implication) operatorVincent Ambo1-1/+21
Similar to `||`, but inverting the left-hand side. In other words, `a -> b` is essentially rewritten as `!a || b`. Change-Id: I8a62da65ff070b389e46048d047a54279060a97b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6152 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4486 feat(tvix/compiler): implement `||` operatorVincent Ambo3-6/+29
Same dance as `&&` but logically inverted. Change-Id: I213e200e3836527e9abe510f354ee7cd1f70d041 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6151 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4485 feat(tvix/compiler): implement `&&` operatorVincent Ambo1-7/+41
This logical operator is implemented in terms of jumping operations and thus requires slightly different treatment than other binary operators. Change-Id: Ib3d768b70dd7e16014c9b47d770aa74eec60ae92 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6150 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4484 docs(tvix/compiler): add a note on use of unwrap/expect for rnixVincent Ambo1-0/+12
Change-Id: I62ca28285685b69d1883afcf18c6068fc2defb5d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6149 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4483 feat(tvix/eval): implement if/else expressionsVincent Ambo4-5/+84
These expressions use simple jumps to skip the correct expression conditionally in the bytecode by advancing the instruction pointer. Note that these expressions are already covered by a test behind the `nix_tests` feature flag, but adding more is probably sensible. Change-Id: Ibe0eba95d216321c883d3b6b5816e2ab6fe7eef1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6148 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4482 refactor(tvix/value): hide internal string representationVincent Ambo2-13/+16
Wraps the string representation in an additional newtype struct with a private field in order to hide the representation from other modules. This is done in order to avoid accidental leakage of the internals outside of value::string. In fact, this caught a mistake in the compiler module which was directly constructing an internal variant. Change-Id: If4b627d3cff7ab9cd50ca1a3ac73245d4dcf7aef Reviewed-on: https://cl.tvl.fyi/c/depot/+/6147 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4481 refactor(tvix/value): ensure internal attrs representation is hiddenVincent Ambo2-47/+53
Wraps the attrs representation in an additional newtype struct with a private field in order to hide the representation from other modules. This is done in order to avoid accidental leakage of the internals outside of value::attrs. Change-Id: I68d1d02514aa0443df4c39801001a3f1f6cc5d5c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6146 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4480 refactor(tvix/eval): encapsulate list construction in value::listVincent Ambo2-17/+17
Ensuring that the implementation is not leaking out of the module lets us keep things open for optimisations (e.g. empty list or pairs through tuples). Change-Id: I18fd9b7740f28c55736471e16c6b4095a05dd6d0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6145 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4479 feat(tvix/eval): implement list concatenationVincent Ambo7-0/+30
Change-Id: Icdf715d116371a9f139bdf95266410bf967bef25 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6144 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-25 r/4478 feat(tvix/eval): implement binary comparison operatorsVincent Ambo20-7/+121
This is accomplished by simply delegating to the Rust implementations of (Partial)Ord and (Partial)Eq, which are implemented for Value and underlying wrapper types to behave like they do in Nix. To ease the implementation overhead, a new comparison operator macro has been added to the VM module. Incomparable types will raise a new error variant when a comparison is attempted, containing both supplied types. This mimics the information carried in the error thrown by C++ Nix. Change-Id: Ia19634d69119d40722f3ca672387bc3a80096998 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6143 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-25 r/4477 refactor(tvix/vm): simplify implementation of OpEqualVincent Ambo1-8/+1
This can now fully delegate to PartialEq of Value Change-Id: Iaa9f4ec9b8830d516d72f83a93ab2df9a6e5697c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6142 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4476 feat(tvix): implement not-equals (!=) operatorVincent Ambo9-8/+21
Change-Id: Ic259d6d0cf30553e944682a0d1d2c610df7fe5c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6141 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-25 r/4475 feat(tvix/eval): implement attrset update (`//`) operatorVincent Ambo13-1/+87
The underlying implementation does a few tricks based on which pair of attrset representations is encountered. Particularly the effect of short-circuiting the empty cases might be relevant in nixpkgs/NixOS, due to the use of lib.optionalAttrs. Change-Id: I22b978b1c69af12926489a71087c6a6219c012f3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6140 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-25 r/4474 fix(tvix/value): explicitly delegate `Ord` to &str representationVincent Ambo1-1/+9
I assumed that `Ord` is a marker trait like `Eq`, but it actually has a member. Without this ordering was incoherent. Change-Id: Id37cbdf333daf748d29b85243046c7e061b1ce29 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6139 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4473 fix(tvix/value): ensure only string values of NixString are hashedVincent Ambo1-1/+8
Change-Id: I1b97cf5a9e4e235fac72a507de49a8df508bcaa1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6138 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4472 feat(tvix/eval): implement string concatenationVincent Ambo6-1/+23
Change-Id: If61066e59232b2bad42b5cb5f0f2d9b9c416be8b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6137 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4471 refactor(tvix/vm): use a macro to handle binary arithmetic operatorsVincent Ambo1-49/+32
Instead of constructing another runtime value representing the pair on which to perform arithmetic, implement the same logic in the shape of a macro. This is designed to be compatible with operators like `+` that work both as an arithmetic operator AND as an operator on another pair of types. Change-Id: I1c83649ead6117f811f1fb45482d0cadf811125e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6136 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4470 test(tvix/eval): add some eval-okay-* tests for trivial typesVincent Ambo13-16/+50
Change-Id: I85ccc07e08c67abf4fcd3752c58e1702943239ac Reviewed-on: https://cl.tvl.fyi/c/depot/+/6135 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-25 r/4469 fix(tvix/value): fix display representation of floatsVincent Ambo1-1/+7
Nix displays a maximum of 5 digits for floating points. Change-Id: Ifa3c0d96fa0b24e3be8f94dfebc99e602a258355 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6133 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-24 r/4468 chore(tvix/eval): enable test runs in naerskVincent Ambo1-0/+1
Change-Id: I08c3a66a3f5c98d914d17a2ad6de98b1c02e50b2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6134 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4467 test(tvix/eval): add identity tests for literal evaluationVincent Ambo19-2/+56
Change-Id: Id3f37fbe341e15e9428ef1d579d61a514232c0e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6132 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4466 fix(tvix/value): align Display representation with NixVincent Ambo1-6/+2
Displaying the optimised representation is not useful anymore. Change-Id: Icb962ff8865ec4207c144fbcb1aae87483b0fb7c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6131 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4465 docs(tvix/eval): add README note on running the Nix test suiteVincent Ambo1-0/+12
Change-Id: I792154d5fea05414f2b14367ea4087dc2a88758e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6130 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4464 chore(tvix/tests): gate Nix test suite behind `nix_tests` featureVincent Ambo2-0/+6
Once we have full coverage they should be enabled by default. Change-Id: Iace9e1ae9a9f901a0979ad336434004b8028fe8a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6129 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4463 chore(tvix/eval): only print AST if requestedVincent Ambo1-1/+3
Change-Id: If32c7fd03458a27aecb8c473f2c48b12f8cb5175 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6128 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su>
2022-08-24 r/4462 fix(tvix/value): add ident_str representation of stringsVincent Ambo2-8/+25
When printing strings as identifiers (in attribute sets), the string should only be quoted and escaped if it contains escape characters. Change-Id: If2bcfa1e93dc8f00be4d7a57ec1d82fc679103c3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6127 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su>
2022-08-24 r/4461 feat(tvix/tests): check in Nix' language test suiteVincent Ambo248-9/+2217
This adds scaffolding code for running the Nix language test suite. The majority of eval-okay-* tests should eventually be runnable as-is by Tvix, however the eval-fail-* tests might not as we intend to have more useful error messages than upstream Nix. Change-Id: I4f3227f0889c55e4274b804a3072850fb78dd1bd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6126 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4460 chore(tvix/eval): add 'test-generator' as dev-dependencyVincent Ambo2-0/+57
This crate makes it easy to generate test cases from files on disk, which is used for running the Nix test suite against Tvix. Change-Id: I60ef26484d05e723982679dd42958adf52735916 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6125 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4459 fix(tvix/value): add escaping logic for Nix stringsVincent Ambo1-10/+46
Nix strings displayed to users must be escaped the same way as they are in C++ Nix. This adds the scaffolding for escapes, but is most likely not yet complete. Change-Id: Icfdcb2ac98d292c567ba894a92b6529a53e0cc17 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6124 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-24 r/4458 fix(tvix/value): implement PartialOrd/PartialEq for stringsVincent Ambo1-1/+13
Instead of comparing the enum variants (which does not yield useful behaviour), compare &str representations of the string instead. Change-Id: I5e94b5f6c91b4561e1bc7c36d586f3d23c243764 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6112 Tested-by: BuildkiteCI Reviewed-by: eta <tvl@eta.st>
2022-08-24 r/4457 feat(tvix/value): introduce string representation with &'static strVincent Ambo4-26/+44
For cases where the strings are statically known (such as the oft-occuring name/value), this can be a useful optimisation. It's also much more convenient in tests. Change-Id: Ie462b684805bd4986ea5e85ca4bff663bc2d3c3c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6111 Tested-by: BuildkiteCI Reviewed-by: eta <tvl@eta.st>
2022-08-24 r/4456 test(tvix/value): add simple attrset construction testsVincent Ambo3-0/+62
These do not yet test nested attribute sets; we need to add some more inspection primitives first. Change-Id: Icfc99bf17c73ebefc0d882a84f0ca73ec688a54d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6110 Reviewed-by: eta <tvl@eta.st> Tested-by: BuildkiteCI
2022-08-24 r/4455 feat(tvix/value): implement nested attribute set literalsVincent Ambo1-14/+44
With this change, nested attribute sets can now be created from literals. This required some logic for dealing with cases where at a deeper nesting point a literal attribute set was constructed from an optimised representation. For example, this is valid Nix code: ```nix { a = {}; # creates optimised empty representation a.b = 1; # wants to add a `b = 1` to it b = { name = "foo"; value = "bar"; }; # creates optimised K/V repr b.foo = 42; # wants to add an additional `foo = 42` } ``` In these cases, the attribute set must be coerced to a map representation first which is achieved by the new internal NixAttr::map_mut helper. Change-Id: Ia61d3d9d14c4e0f5e207c00f6a2f4daa3265afb2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6109 Reviewed-by: eta <tvl@eta.st> Tested-by: BuildkiteCI
2022-08-24 r/4454 refactor(tvix/value): encapsulate attrset logic within value::attrsVincent Ambo3-191/+194
The internal optimisations of the set representation were previously leaking into the VM, which is highly undesirable. Keeping it encapsulated allows us to do additional optimisations within value::attrs without being concerned about its use in the VM. Change-Id: I7e7020bb0983b9d355d3db747b049b2faa60131f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6108 Reviewed-by: eta <tvl@eta.st> Tested-by: BuildkiteCI
2022-08-22 r/4453 chore(paroxysm): bump cargo dependenciesVincent Ambo1-89/+183
Change-Id: Ibf82bf6b9a10274fe6928db7a6a2beb74da92b13 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6122 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-22 r/4452 chore(web/atward): bump cargo dependenciesVincent Ambo1-64/+210
Change-Id: I691e87c6b596fcc7028717a5a22d5619bd87a089 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6121 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-22 r/4451 chore(tools/cheddar): bump cargo dependenciesVincent Ambo1-125/+248
Change-Id: I41e26046a67635ec3dba2ac955e31e6ca7451cc6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6120 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-08-22 r/4450 chore(tazjin/tgsa): bump cargo dependenciesVincent Ambo1-98/+195
Change-Id: Id52ab2937e32385324ba93f4df7e1da17a1f4eec Reviewed-on: https://cl.tvl.fyi/c/depot/+/6119 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-08-22 r/4449 chore(3p/sources): Bump channels & overlayssterni5-66/+76
* //users/tazjin/predlozhnik: bump wasm-bindgen & run `cargo update` * //users/Profpatsch/writers: use proper keyword syntax to make make flake8 happy. * //third_party/nixpkgs: pick binaryen from stable channel Change-Id: Ia711d8c396aa09b78413d80f35eedf63fa315596 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6118 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-08-22 r/4448 feat(users/Profpatsch): init haskell arglib-netencodeProfpatsch3-0/+64
Mirrors the rust exec-helpers Change-Id: I96f211d6545e228b8ae0c1dce4e60e6f6867690c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6117 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-08-22 r/4447 feat(users/Profpatsch): init haskell exec-helpersProfpatsch3-0/+80
Mirrors the rust exec-helpers Change-Id: I8fba49525949a8f38ca8c215e2ec7ba9d97d3bf9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6116 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-08-22 r/4446 fix(users/Profpatsch/my-prelude): use exactSourceProfpatsch1-1/+4
Change-Id: I1b797fb69f69e09f2dda99fce2f12adef0ac2ad2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6115 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-08-22 r/4445 feat(users/Profpatsch): init netencode-hsProfpatsch3-0/+445
Haskell implementation of the netncode parser & generators. Change-Id: I904df752e78641110af2857e71d8206bf432d427 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6114 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-08-16 r/4444 chore(sterni/emacs): weed out subscriptionssterni1-26/+2
Change-Id: Ie5f57300c380874a83d1cbd25a61eb595760bbf4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6113 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-08-14 r/4443 refactor(tvix/rm): introduce helper for AttrSet Entry APIVincent Ambo1-20/+27
There are multiple points where an insertion needs to be done into an attribute set, but copying the key or checking for presence before insertion should be avoided As that is a little bit noisy, it's been factored out into a helper function in this commit. Change-Id: Ibcb054ebeb25a1236c06c812f47c8e74180d4fc9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6107 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>