From 63aa21c581933a10b2b1ab96c632c72834cf2115 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 15 Apr 2019 12:22:02 +0200 Subject: Handle empty optionals correctly Closes #78 --- dhall_core/src/printer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dhall_core/src/printer.rs') diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs index e53c1ec..bb094de 100644 --- a/dhall_core/src/printer.rs +++ b/dhall_core/src/printer.rs @@ -32,6 +32,12 @@ impl Display for ExprF { NEListLit(es) => { fmt_list("[", ", ", "]", es, f, Display::fmt)?; } + OldOptionalLit(None, t) => { + write!(f, "[] : Optional {}", t)?; + } + OldOptionalLit(Some(x), t) => { + write!(f, "[{}] : Optional {}", x, t)?; + } EmptyOptionalLit(t) => { write!(f, "None {}", t)?; } @@ -149,6 +155,7 @@ impl Expr { | Let(_, _, _, _) | EmptyListLit(_) | NEListLit(_) + | OldOptionalLit(_, _) | EmptyOptionalLit(_) | NEOptionalLit(_) | Merge(_, _, _) @@ -189,6 +196,7 @@ impl Expr { b.phase(PrintPhase::BinOp(op)), ), EmptyListLit(t) => EmptyListLit(t.phase(Import)), + OldOptionalLit(x, t) => OldOptionalLit(x, t.phase(Import)), EmptyOptionalLit(t) => EmptyOptionalLit(t.phase(Import)), NEOptionalLit(e) => NEOptionalLit(e.phase(Import)), ExprF::App(a, args) => ExprF::App( -- cgit v1.2.3