about summary refs log tree commit diff
path: root/tvix
AgeCommit message (Collapse)AuthorFilesLines
2022-10-03 r/5019 feat(tvix/eval): implement tail-calling of __functor attributesVincent Ambo3-19/+39
This implements __functor calling in situations where `OpTailCall` is used, but not yet for `OpCall`. For some reason I have not yet figured out, this same implementation does not work in call_value, which means that it also doesn't yet work in builtins that apply functions. Change-Id: I378f9065ac53d4c05166a7d0151acb1f55c91579 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6826 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-10-02 r/5018 feat(tvix/eval): Add passthru build for benchmark binariesGriffin Smith1-4/+16
Add a new derivation target to the passthru of tvix.eval that builds the benchmark binaries, *and* copies them to the outupts of the derivation via the (somewhat arcane) `copyBinsFilter` jq script arg to naersk. This is a bit annoying because (as far as I can tell) the derivations returned by naersk aren't directly overridable, so we have to explicitly fixpoint the attrs we're passing. Also, since this is now a separate target to build the benchmarks, we can remove `--all-targets` from the build of `tvix-eval` itself since that was only added to build benchmarks in CI, and make regular (non-benchmark) builds a bit faster. Change-Id: I136b8526790545e93b1ae666abaefb51cbbee390 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6847 Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-10-01 r/5008 docs(tvix/eval): start doc about problematic/weird lang behaviorsterni1-0/+39
The idea is that we can keep track of the more unexpected behavior, behavior that maybe should not be a thing at all and behavior we are not sure about yet. Change-Id: I70933f00af1230a7ab9d30e917b61199fe571caf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6803 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-30 r/5006 fix(tvix/eval): fix thunk borrowing error in force_for_outputVincent Ambo3-1/+7
This function previously kept a borrow in the form of the `Thunk::value` result alive while performing arbitrary actions in the VM, which caused a borrowing error in the test case attached. The `Ref` value must never be used in cases where control flow is passed to other parts of the VM. Change-Id: I41d10aa1882a2166614b670e8ba77aab0e67deca Reviewed-on: https://cl.tvl.fyi/c/depot/+/6825 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-30 r/5005 test(tvix/eval): add simple nested key tests in let & rec attrsVincent Ambo4-0/+10
Change-Id: Icdc41ae383cd7cd1531c65c97d955bc59a56489a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6809 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-30 r/5004 chore(tvix/eval): remove unused field in TrackedBindingsVincent Ambo1-7/+3
Change-Id: I65e31e9173e4f5bba19cc4e3d45eb4f8bf91b424 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6808 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-30 r/5003 test(tvix/eval): reactivate nested key tests in plain attribute setsVincent Ambo9-0/+0
Change-Id: Id25cde5a6562e1598dcbbf7945ecdfacac5faed7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6807 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-30 r/5002 feat(tvix/eval): implement nested keysVincent Ambo1-29/+60
This finishes up the implementation of nested keys after the key insight that the nesting level does not need to be tracked, and instead the attribute iterator can simply be retained inside the structures as is (in an advanced state). With this implementation, when encountering a nested key, the Tvix compiler will first analyse whether there is already a matching binding that can be merged (i.e. a binding that is a literal attribute set), and perform the merge, or otherwise create a new recursive set of bindings in which the entry is inserted with the path iterator advanced beyond the first name component. With this, all the logic simply applies recursively until there are no more nested bindings (i.e. until all iterators are "empty"). Note that this has one (potentially insignificant) deviation from Nix currently: If a non-mergable value is supplied (e.g. `a.b = 1; a = 2;`), Tvix will emit a *runtime* error (whereas it is *parse* time in Nix) as the branch which could statically analyse this is currently unreachable. There's a TODO for this, so we can fix it up later. Change-Id: I53df70e09614ff4281a70b80eac7da3beca12da9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6806 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-30 r/5001 refactor(tvix/eval): split out AttributeSet::from_ast helperVincent Ambo1-26/+31
Change-Id: Id43dbd06aef14cf01b4901d9b3668d790cd2b5ae Reviewed-on: https://cl.tvl.fyi/c/depot/+/6805 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-30 r/5000 chore(tvix/eval): remove `nesting_level` trackingVincent Ambo1-25/+2
This is actually quite useless, as we can just pass `AstChildren<ast::Attr>` around after partially consuming it. Change-Id: If0aefa2b53fc801fced1ae0709bff93966bf19f8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6804 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-09-29 r/4999 refactor(tvix/eval): clean up representation flip in bindingsVincent Ambo1-37/+32
When encountering a nested binding for the first time, cleanly flip the representation to `Binding::Set` in `Binding::merge` before proceeding with the actual merge. This reduces the number of points where we have to deal with the (soon to be slightly more complex) construction of the nested binding representation. Change-Id: Ifd43aac7b59ebd15a72c3ec512386a5bcf26ec13 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6802 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4998 feat(tvix/eval): (partially) track nesting level of attrsetsVincent Ambo1-29/+82
This adds the scaffolding required for tracking the nesting level (and appropriately skipping the correct amount of attrpath entries when inserting nested sets). In order for all of this to work correctly, we can no longer track `AttrpathValue` directly in the entries vector as rnix does not allow us to construct values of that type - so instead we have to track its inner components. Change-Id: Icb18e105586bf6c247c2e66c302cde5609ad9789 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6801 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4997 feat(tvix/eval): merge attribute sets in bindingsVincent Ambo5-13/+133
This is a significant step towards correctly implemented nested bindings. All attribute sets defined within the same binding scope will now be merged as in Nix, if they use the same key. Change-Id: I13e056693d5e73192280043c6dd93b47d1306ed6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6800 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4996 feat(tvix/eval): add error kind for unmergeable nested attributesVincent Ambo2-1/+14
Change-Id: Ic5e6d1bf2625c33938360affb0d1a7c922af11bf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6799 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4995 feat(tvix/eval): add scaffolding for merging nested attribute setsVincent Ambo2-25/+116
This sets up the required logic for finding and merging attribute sets into nested bindings if they exist. This is absolutely not complete yet and can, at this commit, probably cause undefined runtime behaviour if nested attributes are specified. The basic idea is that a new helper function on the `TrackedBindings` struct is called with each encountered attribute and determines whether the new entry can be merged into an existing attribute or not. Right now the only effect this has in practice is that a new error becomes available if somebody attempts to cause a merge into an inherited key. Change-Id: Id010df3605055eb1ad7fa65241055889dd21bab0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6798 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4994 refactor(tvix/eval): emit OpAttrs inside of compile_bindingsVincent Ambo2-6/+6
This needs to move here so that we can reuse compile_bindings for the nested attribute sets we're about to start constructing. Change-Id: Ie83f52f7e1d128886e96a1da47792211fa826f21 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6796 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4993 refactor(tvix/eval): introduce `TrackedBindings` structVincent Ambo1-11/+34
This struct will be the key to correctly compiling nested bindings, by having insertions flow through some logic that will attempt to bind attribute-set-like things when encountering them. Change-Id: I8b5b20798de60688f3b6dc4526a460ebb2079f6e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6795 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4992 refactor(tvix/eval): compile_recursive_scope -> compile_bindingsVincent Ambo1-4/+4
Change-Id: Iff18d0f84ba2b7a4194797e6c52c55b1c37e419c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6794 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4991 chore(tvix/eval): fix all current clippy lintsVincent Ambo4-6/+6
Change-Id: I28d6af8cb408f8427a75d30b9120aaa809a1ea40 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6784 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4990 chore(tvix/eval): remove existing nested key implementationVincent Ambo4-101/+3
This implementation, which only ever worked for non-recursive attribute sets, is no longer needed and thus removed here. We have a new implementation of these nested keys coming up instead. Change-Id: I0c2875154026a4f5f6e0aa038e465f54444bf721 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6783 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4989 refactor(tvix/eval): merge all bindings creation logicVincent Ambo13-138/+8
As of this commit, all three types of bindings scopes are compiled the same way (i.e. compilation of non-recursive attribute sets has been switched over to the new code paths). This sets us up for doing the final implementation of nested attribute sets. HOWEVER, this breaks the existing implementation of nested attributes in non-recursive attribute sets. That implementation is flawed and unworkable in practice, so we need to do this dance to be able to implement it correctly. Change-Id: Iba2545c0d1d6b51f5e1a31a5d005b8d01da546d3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6782 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4988 feat(tvix/eval): implement dynamic keys in recursive attrsVincent Ambo3-29/+39
This wires up the new bindings setup logic to be able to thread through & compile dynamic attributes in recursive attrs. It seems like we don't actually need to retain the phasing of Nix exactly, as we can use the phantom mechanism to declare all locals without making the dynamic ones accessible. Change-Id: Ic2d43dd8fd97d7ccd56d8c6adf2ff97274cd837a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6781 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-29 r/4986 feat(tvix/eval): add KeySlot::Dynamic variant for dynamic keysVincent Ambo1-14/+29
Another slice of the salami, but no functionality changes yet (other than opening a code path that can reach a `todo!()`, but this will be removed soon). Change-Id: I56b4ed323f70754ed1ab27964ee3c99cf3bf3292 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6780 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4985 refactor(tvix/eval): clean up unused attrpath normalisation logicVincent Ambo1-52/+36
The previous way of sanitising dynamic keys is going away as we're slowly introducing the new nested key logic. While touching this stuff, I've also changed all the related string types to SmolStr as that is more sensible for identifiers. Change-Id: If30c74151508719d646d0e68e7d6f62c36f4d23f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6779 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4984 chore(tvix/eval): reflow comments in compiler::bindingsVincent Ambo1-101/+88
Change-Id: I6d74f71ecd671feaec96ee4ff39f218907c517fe Reviewed-on: https://cl.tvl.fyi/c/depot/+/6777 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4983 refactor(tvix/eval): merge inherits logic between all binding kindsVincent Ambo1-80/+8
Removes the `compile_inherit_attrs` logic which was only used for BindingsKind::Attrs (i.e. non-recursive attrs). This brings us a step closer to fully merging all the binding logic into one block that can dispatch based on the kind of bindings (and thus giving us a good point to introduce the final logic for nested bindings). Change-Id: If48d7a9497fc084a5cc03a130c2a7da5e2b8ef0c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6776 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-29 r/4982 refactor(tvix/eval): Factor out `declare_bindings` helperVincent Ambo1-41/+63
This helper is responsible for declaring the bindings in the compiler's scope tracking structures. It is almost equivalent to the previous logic, but also accounts for `BindingsKind::Attrs` - though those code paths do not end up here yet. Change-Id: I44f617b99b10f2a7b9675f7b23e2c803a4a93d29 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6775 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-28 r/4980 chore(3p/sources): Bump channels & overlayssterni1-1/+1
Upstream nixpkgs removed a lot of aliases this time, so we needed to do the following transformations. It's a real shame that aliases only really become discoverable easily when they are removed. * runCommandNoCC -> runCommand * gmailieer -> lieer We also need to work around the fact that home-manager hasn't catched on to this rename. * mysql -> mariadb * pkgconfig -> pkg-config This also affects our Nix fork which needs to be bumped. * prometheus_client -> prometheus-client * rxvt_unicode -> rxvt-unicode-unwrapped * nix-review -> nixpkgs-review * oauth2_proxy -> oauth2-proxy Additionally, some Go-related builders decided to drop support for passing the sha256 hash in directly, so we need to use the generic hash arguments. Change-Id: I84aaa225ef18962937f8616a9ff064822f0d5dc3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6792 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: wpcarro <wpcarro@gmail.com>
2022-09-28 r/4979 refactor(tvix/eval): Factor out `bind_values` helperVincent Ambo1-47/+55
This is responsible for actually setting up `TrackedBinding`s on the stack, i.e. in some sense "actually compiling" values in bindings. There is no functionality change to before, i.e. this is a salami slice. Change-Id: Idb0312038e004470a7d130c020ae0fe87c55c218 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6774 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-28 r/4978 refactor(tvix/eval): split `compile_inherits` into twoVincent Ambo1-12/+29
Splits the large `compile_inherits` function which previously *compiled* plain inherits and *declared* namespaced inherits into `compile_plain_inherits` and `declare_namespaced_inherits`. This is supposed to make more sense than before, but is still not consistently used (notably, non-recursive attribute sets still duplicate most of this logic). Another salami slice. Change-Id: Id97fac1cbd5ee97b24d047e7728655e6b7734153 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6773 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-28 r/4977 refactor(tvix/eval): add non-recursive logic to `compile_inherit`Vincent Ambo1-16/+39
... but do not use it yet. This refactoring is pretty complicated, so I'm applying salami-slicing tactics here. Change-Id: I66e04ee10548f68bf67dc842f3f14cc279426c22 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6772 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-28 r/4976 refactor(tvix/eval): introduce type to track kind of bindingsVincent Ambo1-11/+30
As part of the unification of binding logic between different carriers of bindings, we need to track which kind of bindings we are dealing with (attribute set? recursive scope? ...) to correctly emit keys and declare identifiers in the locals stack. Right now this changes no functionality as `BindingsKind::Attrs` is not yet used (only RecAttrs and LetIn, which was previously represented by the `rec_attrs` boolean). Change-Id: Id2ac27894079ab584521cb568d75c124f7bf2403 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6771 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-28 r/4975 refactor(tvix/eval): move recursive inherit logic into helperVincent Ambo1-98/+108
This helper will gain the ability to compile both kinds of inherits, but it is kind of tricky to get right so I am doing it in smaller steps. Right now there is no change in functionality. Change-Id: Ie990b88dd90a5e0f9fd79961ee09a6c83f2c872d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6770 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-09-28 r/4974 refactor(tvix/eval): rename BindingKind -> BindingVincent Ambo1-7/+7
This just describes a binding, and we do need a good name for the kind of binding*s*, which is going to be introduced soon. Change-Id: I53900ee52da8a07dae8b918fa6a4cb308e627efb Reviewed-on: https://cl.tvl.fyi/c/depot/+/6768 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-28 r/4973 refactor(tvix/eval): generalise error variant for dynamic keysVincent Ambo2-31/+17
Change-Id: I08f40b4b53652a519e76d6e8344c7c3fe10a0689 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6767 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-28 r/4972 refactor(tvix/eval): bye compiler::attrs, hello compiler::bindingsVincent Ambo3-803/+810
Changes the module structure of the compiler to have a module dedicated to the logic of setting up bindings. This logic is in the process of being merged between attribute sets and `let`-expressions, and the structure of the modules makes more sense when ecapsulating that specifically. (Other bits of code related to e.g. attribute sets are pretty straightforward and can just live in the main compiler module). Change-Id: I9469b73a7034e5b5f3bb211694d97260c4c9ef54 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6766 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-23 r/4964 chore(tvix/eval): mark coerce_value_to_path as intentionally unusedVincent Ambo1-0/+1
This was added in preparation for some builtins that don't exist yet and is producing some noise during compilation. Change-Id: I51fb0d14c3edf0bd6d9a288d50e44dacf35166c6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6769 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-09-23 r/4963 feat(tvix/eval): implement 'builtins.filter'Vincent Ambo4-1/+44
This is a little ugly because the plain Iterator::filter method can not be used (it does not support fallible primitives), so we need to resort to an `Iterator::filter_map` and deal with the wrapping in Options everywhere. This prevents use of `?` which introduces the need for some matching, but it's not *too* bad. Change-Id: Ie2c3c0c9756c4c627176f64fb4e0054e717c26d1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6765 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-22 r/4962 fix(tvix/eval): manually count entries in recursive scopesVincent Ambo4-4/+14
The previous version had a bug where we assumed that the number of entries in an attribute set AST node would be equivalent to the number of entries in the runtime attribute set, but due to inherit nodes containing a variable number of entries, this did not work out. Fixes b/199 Change-Id: I6f7f7729f3512b297cf29a2e046302ca28477854 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6749 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-22 r/4961 feat(tvix/eval): add builtins.stringLengthsterni3-0/+16
Fairly straightforward, only thing of note is that we coerce (weakly) to string here as well. Change-Id: I03b427e657e402f1f9eb0f795b689bbf5092aba1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6745 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-22 r/4960 fix(tvix/eval): handle thunks in arithmetic builtinssterni10-28/+32
The simplest solution seems to be to pass references to arithmetic_op!() which avoids the moving annoyance we had to deal with in the builtins (no more popping!). We then use .force() to force the values and dereference any Thunks (which arithmetic_op! doesn't do for us). Change-Id: I0eb8ad60e80a0b3ba9d9f411e973ef8bcf136989 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6724 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-22 r/4959 test(tvix/eval): add a test for accessing "strange" identifiersVincent Ambo2-0/+9
Because `inherit` can take string identifiers, we can access arbitrarily weird identifiers in scopes using it. Change-Id: Ic868233221befa160538dd2ffaff1cc7f566585a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6748 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-22 r/4958 fix(tvix/eval): support string identifiers in inheritsVincent Ambo7-78/+135
This updates rnix-parser to a version where inherits provide an iterator over `ast::Attr` instead of `ast::Ident`, which mirrors the behaviour of Nix (inherits can have (statically known) strings as their identifiers). This actually required some fairly significant code reshuffling in the compiler, as there was an implicit assumption in many places that we would have an `ast::Ident` node available when dealing with variable access (which is then explicitly only not true in this case). Change-Id: I12f1e786c0030c85107b1aa409bd49adb5465546 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6747 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-22 r/4957 test(tvix/eval): test word behavior in builtins.compareVersionssterni2-1/+6
We delegate to Rust std's Ord trait, so we should at least do a sanity check here. Change-Id: I9596068f8ab3e51b79602de0bac79af6d558086e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6723 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-22 r/4955 feat(tvix/eval): Support builtins.lessThanWilliam Carroll4-14/+42
Extend and export the `cmp_op`, and this becomes trivial. Change-Id: I9c93fa4db0f5a1fc8b56928ea144676f79247de1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6557 Autosubmit: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-22 r/4954 feat(tvix/eval): Sketch out impure builtinsGriffin Smith3-3/+23
Sketch out a new set of "impure" builtins, which supplement the existing set of "pure" builtins but are gated behind a feature flag, which allows them to be omitted by crates depending on tvix-eval that only want pure evaluation, such as tvixbolt. Change-Id: I2736017b5c9b4776bbba8758e108ec84887abd66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6655 Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-21 r/4953 refactor(tvix/eval): drop empty Word version cmp rulesterni1-4/+0
This was derived from else if (c1 == "" && n2) return true; // true implies c1 < n2 However, this has no effect since Word always looses out against Number anyways and the `pre` rules are also unaffected by this change – since this only affects comparison of an empty Word part with a Number. Change-Id: Ia04e42ac726352b688c87674b0fdb355f06edbcb Reviewed-on: https://cl.tvl.fyi/c/depot/+/6722 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-21 r/4952 test(tvix/eval): add more compareVersions test cases involving presterni2-1/+7
This asserts the not-quite lexicographical property of the comparison. Change-Id: Iad68081e4b3a7106513f479643de87065dc47739 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6721 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-21 r/4951 test(tvix/eval): add more compareVersions cases from C++ Nixsterni2-1/+15
Change-Id: I25e7e7a2c547d0874e1e949bf96e6e066b1075ed Reviewed-on: https://cl.tvl.fyi/c/depot/+/6705 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-21 r/4950 fix(tvix/eval): compare versions with an extra empty componentsterni2-2/+17
This is necessary because builtins.compareVersions compares versions in a subtly not-quite-but-still-lexicographical way: `pre` for example can have an effect if it is post-fixed: `2.3 < 2.3pre`. This is a violation of the rule that in a lexicographical ordering, the longer string is considered greater if they are otherwise equal. builtins.compareVersion is comparing lexicographically though, if you do the following transformation beforehand: 2.3 --split--> [ "2" "3" ] --append--> [ "2" "3" "" ] 2.3pre --split--> [ "2" "3" "pre" ] --append--> [ "2" "3" "pre" "" ] Comparing the transformed version is then done lexicographically: 2.3 < 2.3.0pre since [ "2" "3" "" ] < [ "2" "3" "0" "pre" ] Here, the `pre` rule never comes into effect because no comparison on it happens, instead we use the longer string rule of a lexicographical comparison. In the C++ codebase, the reason for this behavior is that the iterator-esque construct they use always yields the empty string before it exposes it has been fully consumed. This is probably intentional to support the postfixed `pre` which is, for example, used by NixOS versions (e.g. unstable post 22.05 is 22.11-pre). We replicate this behavior using the `Chain` iterator in `VersionPartsIter::new_for_cmp`. Change-Id: I021c69aa27b0b7deb949dffe50ed18b6de3a7b1f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6720 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>