From 092b7208ffd22f8facc7af387ac307e59208d52c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 7 Apr 2020 11:19:36 +0100 Subject: Move duplicate field checking to parser --- dhall/src/builtins.rs | 8 +- dhall/src/operations.rs | 13 +- dhall/src/semantics/resolve/resolve.rs | 4 +- dhall/src/semantics/tck/typecheck.rs | 61 +++---- dhall/src/syntax/ast/expr.rs | 5 +- dhall/src/syntax/ast/map.rs | 282 --------------------------------- dhall/src/syntax/ast/mod.rs | 1 - dhall/src/syntax/binary/encode.rs | 13 +- dhall/src/syntax/text/parser.rs | 64 ++++++-- 9 files changed, 90 insertions(+), 361 deletions(-) delete mode 100644 dhall/src/syntax/ast/map.rs (limited to 'dhall/src') diff --git a/dhall/src/builtins.rs b/dhall/src/builtins.rs index bb8173c..67929a0 100644 --- a/dhall/src/builtins.rs +++ b/dhall/src/builtins.rs @@ -1,15 +1,15 @@ +use std::collections::{BTreeMap, HashMap}; +use std::convert::TryInto; + use crate::operations::{BinOp, OpKind}; use crate::semantics::{ skip_resolve_expr, typecheck, Hir, HirKind, Nir, NirKind, NzEnv, VarEnv, }; -use crate::syntax::map::DupTreeMap; use crate::syntax::Const::Type; use crate::syntax::{ Const, Expr, ExprKind, InterpolatedText, InterpolatedTextContents, Label, NaiveDouble, NumKind, Span, UnspannedExpr, V, }; -use std::collections::HashMap; -use std::convert::TryInto; /// Built-ins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -147,7 +147,7 @@ macro_rules! make_type { ))) }; ({ $($label:ident : $ty:ident),* }) => {{ - let mut kts = DupTreeMap::new(); + let mut kts = BTreeMap::new(); $( kts.insert( Label::from(stringify!($label)), diff --git a/dhall/src/operations.rs b/dhall/src/operations.rs index 1ebf288..8b5fa10 100644 --- a/dhall/src/operations.rs +++ b/dhall/src/operations.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use std::borrow::Cow; use std::cmp::max; -use std::collections::HashMap; +use std::collections::{BTreeSet, HashMap}; use crate::builtins::Builtin; use crate::error::{ErrorBuilder, TypeError}; @@ -9,7 +9,6 @@ use crate::semantics::{ merge_maps, mk_span_err, mkerr, ret_kind, ret_op, ret_ref, Binder, Closure, Hir, HirKind, Nir, NirKind, Ret, TextLit, Tir, TyEnv, Type, }; -use crate::syntax::map::DupTreeSet; use crate::syntax::{trivial_result, Const, ExprKind, Label, NumKind, Span}; // Definition order must match precedence order for @@ -60,7 +59,7 @@ pub enum OpKind { /// `e.x` Field(SubExpr, Label), /// `e.{ x, y, z }` - Projection(SubExpr, DupTreeSet