From 2020d41874f7681ba948a40d8e8f8993d651a81c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 9 May 2019 12:48:41 +0200 Subject: Detect duplicate record fields in typecheck --- dhall_syntax/src/core/visitor.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'dhall_syntax/src/core/visitor.rs') diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 20bfc72..1377849 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use crate::*; /// A way too generic Visitor trait. @@ -68,10 +66,10 @@ where None => None, }) } - fn btmap<'a, V, Ret, SE, L, E>( - x: &'a BTreeMap, + fn vecmap<'a, V, Ret, SE, L, E>( + x: &'a Vec<(L, SE)>, mut v: V, - ) -> Result, V::Error> + ) -> Result, V::Error> where L: Ord, V::L2: Ord, @@ -81,10 +79,10 @@ where .map(|(k, x)| Ok((v.visit_label(k)?, v.visit_subexpr(x)?))) .collect() } - fn btoptmap<'a, V, Ret, SE, L, E>( - x: &'a BTreeMap>, + fn vecoptmap<'a, V, Ret, SE, L, E>( + x: &'a Vec<(L, Option)>, mut v: V, - ) -> Result>, V::Error> + ) -> Result)>, V::Error> where L: Ord, V::L2: Ord, @@ -147,13 +145,13 @@ where v.visit_subexpr(t)?, ), SomeLit(e) => SomeLit(v.visit_subexpr(e)?), - RecordType(kts) => RecordType(btmap(kts, v)?), - RecordLit(kvs) => RecordLit(btmap(kvs, v)?), - UnionType(kts) => UnionType(btoptmap(kts, v)?), + RecordType(kts) => RecordType(vecmap(kts, v)?), + RecordLit(kvs) => RecordLit(vecmap(kvs, v)?), + UnionType(kts) => UnionType(vecoptmap(kts, v)?), UnionLit(k, x, kts) => UnionLit( v.visit_label(k)?, v.visit_subexpr(x)?, - btoptmap(kts, v)?, + vecoptmap(kts, v)?, ), Merge(x, y, t) => Merge( v.visit_subexpr(x)?, -- cgit v1.2.3