summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dhall/tests/tests.rs8
-rw-r--r--dhall_core/src/core.rs57
2 files changed, 24 insertions, 41 deletions
diff --git a/dhall/tests/tests.rs b/dhall/tests/tests.rs
index 83d4a3c..70de466 100644
--- a/dhall/tests/tests.rs
+++ b/dhall/tests/tests.rs
@@ -79,10 +79,10 @@ make_spec_test!(normalization, spec_normalization_success_prelude_List_null_1, "
// make_spec_test!(normalization, spec_normalization_success_prelude_List_replicate_1, "normalization/success/prelude/List/replicate/1");
make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_0, "normalization/success/prelude/List/reverse/0");
make_spec_test!(normalization, spec_normalization_success_prelude_List_reverse_1, "normalization/success/prelude/List/reverse/1");
-// make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_0, "normalization/success/prelude/List/shifted/0");
-// make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_1, "normalization/success/prelude/List/shifted/1");
-// make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_0, "normalization/success/prelude/List/unzip/0");
-// make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_1, "normalization/success/prelude/List/unzip/1");
+make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_0, "normalization/success/prelude/List/shifted/0");
+make_spec_test!(normalization, spec_normalization_success_prelude_List_shifted_1, "normalization/success/prelude/List/shifted/1");
+make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_0, "normalization/success/prelude/List/unzip/0");
+make_spec_test!(normalization, spec_normalization_success_prelude_List_unzip_1, "normalization/success/prelude/List/unzip/1");
// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_build_0, "normalization/success/prelude/Natural/build/0");
// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_build_1, "normalization/success/prelude/Natural/build/1");
// make_spec_test!(normalization, spec_normalization_success_prelude_Natural_enumerate_0, "normalization/success/prelude/Natural/enumerate/0");
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 481e949..9c96b2a 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -405,6 +405,7 @@ impl<S, A: Display> Display for Expr<S, A> {
}
}
+// WARNING: this may cause stack overflows when adding new variants
impl<S, A: Display> Expr<S, A> {
fn fmt_b(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use crate::Expr::*;
@@ -495,44 +496,26 @@ impl<S, A: Display> Expr<S, A> {
use crate::Expr::*;
match self {
// FIXME precedence
- &BinOp(BoolOr, ref a, ref b) => {
+ &BinOp(op, ref a, ref b) => {
a.fmt_d(f)?;
- f.write_str(" || ")?;
- b.fmt_c(f)
- }
- &BinOp(TextAppend, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" ++ ")?;
- b.fmt_c(f)
- }
- &BinOp(NaturalPlus, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" + ")?;
- b.fmt_c(f)
- }
- &BinOp(BoolAnd, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" && ")?;
- b.fmt_c(f)
- }
- &BinOp(Combine, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" ^ ")?;
- b.fmt_c(f)
- }
- &BinOp(NaturalTimes, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" * ")?;
- b.fmt_c(f)
- }
- &BinOp(BoolEQ, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" == ")?;
- b.fmt_c(f)
- }
- &BinOp(BoolNE, ref a, ref b) => {
- a.fmt_d(f)?;
- f.write_str(" != ")?;
+ write!(
+ f,
+ " {} ",
+ match op {
+ BoolOr => "||",
+ TextAppend => "++",
+ NaturalPlus => "+",
+ BoolAnd => "&&",
+ Combine => "^",
+ NaturalTimes => "*",
+ BoolEQ => "==",
+ BoolNE => "!=",
+ CombineTypes => "//\\",
+ ImportAlt => "?",
+ Prefer => "//",
+ ListAppend => "#",
+ }
+ )?;
b.fmt_c(f)
}
&Note(_, ref b) => b.fmt_c(f),