diff --git a/compiler/erg_parser/ast.rs b/compiler/erg_parser/ast.rs index 2097ba8d..af8ecc7c 100644 --- a/compiler/erg_parser/ast.rs +++ b/compiler/erg_parser/ast.rs @@ -1979,7 +1979,13 @@ impl fmt::Display for TypeSpec { } write!(f, "}}") } - Self::Enum(elems) => write!(f, "{{{elems}}}"), + Self::Enum(elems) => { + write!(f, "{{")?; + for elem in elems.pos_args() { + write!(f, "{}, ", elem.expr)?; + } + write!(f, "}}") + } Self::Interval { op, lhs, rhs } => write!(f, "{lhs}{}{rhs}", op.inspect()), Self::Subr(s) => write!(f, "{s}"), Self::TypeApp { spec, args } => write!(f, "{spec}{args}"), diff --git a/compiler/erg_parser/desugar.rs b/compiler/erg_parser/desugar.rs index e7adc2e0..7548998c 100644 --- a/compiler/erg_parser/desugar.rs +++ b/compiler/erg_parser/desugar.rs @@ -992,6 +992,17 @@ impl Desugarer { insertion_idx += 1; insertion_idx } + ParamPattern::Lit(l) => { + let lit = l.clone(); + sig.pat = ParamPattern::Discard(Token::new( + TokenKind::UBar, + "_", + l.ln_begin().unwrap(), + l.col_begin().unwrap(), + )); + sig.t_spec = Some(TypeSpecWithOp::new(COLON, TypeSpec::enum_t_spec(vec![lit]))); + insertion_idx + } _ => insertion_idx, } }