diff --git a/src/format.jule b/src/format.jule index 7394188..a10c078 100644 --- a/src/format.jule +++ b/src/format.jule @@ -1325,9 +1325,13 @@ impl ExprFormatter { } fn cast(&self, mut c: &ast::CastExpr) { - self.write("(") - self.fmt.format_type(c.kind) - self.write(")") + if is_prim_type(c.kind) { + self.fmt.format_type(c.kind) + } else { + self.write("(") + self.fmt.format_type(c.kind) + self.write(")") + } // Do not write parentheses for expression. // Expression formatter will add. self.format(c.expr) @@ -1693,3 +1697,11 @@ fn padding_abs(x: int): int { } ret x } + +fn is_prim_type(&t: &ast::TypeDecl): bool { + match type t.kind { + | &ast::IdentTypeDecl: + ret (&ast::IdentTypeDecl)(t.kind).is_prim() + } + ret false +}