From e1d25891638597b0085033fd99814fce83fab4b9 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 23 Jan 2024 14:54:27 +0200 Subject: fix(tvix/eval/value/function): use BTreeMap for function arg names At least toXML wants to get these out in a sorted fashion. Change-Id: I6373d7488fff7c40dc2ddeeecd03ba537c92c4af Reviewed-on: https://cl.tvl.fyi/c/depot/+/10685 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/compiler/mod.rs | 4 ++-- tvix/eval/src/value/function.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 5e0c1899c0..4bb734290c 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -21,7 +21,7 @@ mod scope; use codemap::Span; use rnix::ast::{self, AstToken}; use smol_str::SmolStr; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::path::{Path, PathBuf}; use std::rc::{Rc, Weak}; use std::sync::Arc; @@ -994,7 +994,7 @@ impl Compiler<'_> { // the bindings to first declare them, then populate them, and // then finalise any necessary recursion into the scope. let mut entries: Vec = vec![]; - let mut arguments = HashMap::default(); + let mut arguments = BTreeMap::default(); for entry in pattern.pat_entries() { let ident = entry.ident().unwrap(); diff --git a/tvix/eval/src/value/function.rs b/tvix/eval/src/value/function.rs index 77ac7112d2..8131cffa02 100644 --- a/tvix/eval/src/value/function.rs +++ b/tvix/eval/src/value/function.rs @@ -1,5 +1,5 @@ //! This module implements the runtime representation of functions. -use std::{collections::HashMap, hash::Hash, rc::Rc}; +use std::{collections::BTreeMap, hash::Hash, rc::Rc}; use codemap::Span; use smol_str::SmolStr; @@ -11,7 +11,7 @@ use super::NixString; #[derive(Clone, Debug, PartialEq)] pub(crate) struct Formals { /// Map from argument name, to whether that argument is required - pub(crate) arguments: HashMap, + pub(crate) arguments: BTreeMap, /// Do the formals of this function accept extra arguments pub(crate) ellipsis: bool, @@ -27,7 +27,7 @@ impl Formals { /// ellipsis pub(crate) fn contains(&self, arg: &Q) -> bool where - Q: ?Sized + Hash + Eq, + Q: ?Sized + Hash + Ord + Eq, NixString: std::borrow::Borrow, { self.ellipsis || self.arguments.contains_key(arg) -- cgit 1.4.1