From 8528096a31c1e9c96eef93317b4f44890f779615 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Wed, 14 Dec 2022 08:04:48 +0900 Subject: [PATCH] Fix type formatting --- compiler/erg_compiler/ty/free.rs | 36 +++++++++++++++++++------------- compiler/erg_compiler/ty/mod.rs | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/compiler/erg_compiler/ty/free.rs b/compiler/erg_compiler/ty/free.rs index cc7da214..e465ccb4 100644 --- a/compiler/erg_compiler/ty/free.rs +++ b/compiler/erg_compiler/ty/free.rs @@ -255,14 +255,18 @@ impl LimitedDisplay for FreeKind { constraint, } => { if *lev == GENERIC_LEVEL { - write!(f, "{name}(")?; - constraint.limited_fmt(f, limit - 1)?; - write!(f, ")")?; - } else { - write!(f, "?{name}(")?; - constraint.limited_fmt(f, limit - 1)?; - write!(f, ")")?; + write!(f, "{name}")?; if cfg!(feature = "debug") { + write!(f, "(")?; + constraint.limited_fmt(f, limit - 1)?; + write!(f, ")")?; + } + } else { + write!(f, "?{name}")?; + if cfg!(feature = "debug") { + write!(f, "(")?; + constraint.limited_fmt(f, limit - 1)?; + write!(f, ")")?; write!(f, "[{lev}]")?; } } @@ -274,14 +278,18 @@ impl LimitedDisplay for FreeKind { constraint, } => { if *lev == GENERIC_LEVEL { - write!(f, "%{id}(")?; - constraint.limited_fmt(f, limit - 1)?; - write!(f, ")")?; - } else { - write!(f, "?{id}(")?; - constraint.limited_fmt(f, limit - 1)?; - write!(f, ")")?; + write!(f, "%{id}")?; if cfg!(feature = "debug") { + write!(f, "(")?; + constraint.limited_fmt(f, limit - 1)?; + write!(f, ")")?; + } + } else { + write!(f, "?{id}")?; + if cfg!(feature = "debug") { + write!(f, "(")?; + constraint.limited_fmt(f, limit - 1)?; + write!(f, ")")?; write!(f, "[{lev}]")?; } } diff --git a/compiler/erg_compiler/ty/mod.rs b/compiler/erg_compiler/ty/mod.rs index 9e63146a..4759c070 100644 --- a/compiler/erg_compiler/ty/mod.rs +++ b/compiler/erg_compiler/ty/mod.rs @@ -1192,7 +1192,7 @@ impl LimitedDisplay for Type { write!(f, "|")?; for (i, (name, constr)) in qvars.iter().enumerate() { if i != 0 { - write!(f, "; ")?; + write!(f, ", ")?; } write!(f, "{name}")?; constr.limited_fmt(f, limit - 1)?;