From e6c490e22b7ce208c20698b0d48e7c251282759f Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Fri, 7 Jul 2023 00:31:10 +0900 Subject: [PATCH] fix: type display omittion --- crates/erg_compiler/ty/mod.rs | 5 ++++- crates/erg_compiler/ty/typaram.rs | 3 +++ crates/erg_compiler/ty/value.rs | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/erg_compiler/ty/mod.rs b/crates/erg_compiler/ty/mod.rs index 71be3124..a5146638 100644 --- a/crates/erg_compiler/ty/mod.rs +++ b/crates/erg_compiler/ty/mod.rs @@ -1073,9 +1073,12 @@ impl LimitedDisplay for Type { write!(f, "...")?; break; } - write!(f, "; {field} = ")?; + write!(f, "{field} = ")?; t.limited_fmt(f, limit - 1)?; } + if attrs.is_empty() { + write!(f, "=")?; + } write!(f, "}}") } Self::Subr(sub) => sub.limited_fmt(f, limit), diff --git a/crates/erg_compiler/ty/typaram.rs b/crates/erg_compiler/ty/typaram.rs index 290ebac0..22c53a25 100644 --- a/crates/erg_compiler/ty/typaram.rs +++ b/crates/erg_compiler/ty/typaram.rs @@ -400,6 +400,9 @@ impl LimitedDisplay for TyParam { write!(f, "{field} = ")?; v.limited_fmt(f, limit - 1)?; } + if rec.is_empty() { + write!(f, "=")?; + } write!(f, "}}") } Self::Lambda(lambda) => write!(f, "{lambda}"), diff --git a/crates/erg_compiler/ty/value.rs b/crates/erg_compiler/ty/value.rs index 9781e619..a5fd4646 100644 --- a/crates/erg_compiler/ty/value.rs +++ b/crates/erg_compiler/ty/value.rs @@ -586,7 +586,7 @@ impl LimitedDisplay for ValueObj { match self { Self::Str(s) => { if s.len() >= STR_OMIT_THRESHOLD { - write!(f, "...") + write!(f, "\"(...)\"") } else { write!(f, "\"{}\"", s.escape()) } @@ -662,6 +662,9 @@ impl LimitedDisplay for ValueObj { write!(f, "{field} = ")?; v.limited_fmt(f, limit - 1)?; } + if rec.is_empty() { + write!(f, "=")?; + } write!(f, "}}") } Self::Type(typ) => typ.limited_fmt(f, limit),