diff --git a/crates/lang/src/expr.rs b/crates/lang/src/expr.rs index 989f9384..51487e74 100644 --- a/crates/lang/src/expr.rs +++ b/crates/lang/src/expr.rs @@ -91,12 +91,6 @@ pub enum TypedExpr { kind: AssignmentKind, }, - Trace { - location: Span, - tipo: Arc, - then: Box, - }, - When { location: Span, tipo: Arc, @@ -164,7 +158,6 @@ impl TypedExpr { match self { Self::Negate { .. } => bool(), Self::Var { constructor, .. } => constructor.tipo.clone(), - Self::Trace { then, .. } => then.tipo(), Self::Fn { tipo, .. } | Self::Int { tipo, .. } | Self::Todo { tipo, .. } @@ -207,7 +200,6 @@ impl TypedExpr { match self { TypedExpr::Fn { .. } | TypedExpr::Int { .. } - | TypedExpr::Trace { .. } | TypedExpr::List { .. } | TypedExpr::Call { .. } | TypedExpr::When { .. } @@ -247,7 +239,6 @@ impl TypedExpr { match self { Self::Fn { location, .. } | Self::Int { location, .. } - | Self::Trace { location, .. } | Self::Var { location, .. } | Self::Todo { location, .. } | Self::When { location, .. } @@ -284,7 +275,6 @@ impl TypedExpr { pub fn location(&self) -> Span { match self { Self::Fn { location, .. } - | Self::Trace { location, .. } | Self::Int { location, .. } | Self::Var { location, .. } | Self::Todo { location, .. } @@ -374,12 +364,6 @@ pub enum UntypedExpr { annotation: Option, }, - Trace { - location: Span, - then: Box, - text: Option, - }, - When { location: Span, subjects: Vec, @@ -477,7 +461,6 @@ impl UntypedExpr { pub fn location(&self) -> Span { match self { - Self::Trace { then, .. } => then.location(), Self::PipeLine { expressions, .. } => expressions.last().location(), Self::Fn { location, .. } | Self::Var { location, .. } @@ -515,7 +498,7 @@ impl UntypedExpr { .map(|e| e.start_byte_index()) .unwrap_or(location.start), Self::PipeLine { expressions, .. } => expressions.first().start_byte_index(), - Self::Trace { location, .. } | Self::Assignment { location, .. } => location.start, + Self::Assignment { location, .. } => location.start, _ => self.location().start, } } diff --git a/crates/lang/src/format.rs b/crates/lang/src/format.rs index da68f7d9..8267129a 100644 --- a/crates/lang/src/format.rs +++ b/crates/lang/src/format.rs @@ -751,29 +751,6 @@ impl<'comments> Formatter<'comments> { .. } => self.assignment(pattern, value, None, Some(*kind), annotation), - UntypedExpr::Trace { - text: None, then, .. - } => "trace" - .to_doc() - .append(if self.pop_empty_lines(then.start_byte_index()) { - lines(2) - } else { - line() - }) - .append(self.expr(then)), - - UntypedExpr::Trace { - text: Some(l), - then, - .. - } => docvec!["trace(\"", l, "\")"] - .append(if self.pop_empty_lines(then.start_byte_index()) { - lines(2) - } else { - line() - }) - .append(self.expr(then)), - UntypedExpr::When { subjects, clauses, .. } => self.when(subjects, clauses), @@ -1342,9 +1319,7 @@ impl<'comments> Formatter<'comments> { fn wrap_expr<'a>(&mut self, expr: &'a UntypedExpr) -> Document<'a> { match expr { - UntypedExpr::Sequence { .. } - | UntypedExpr::Assignment { .. } - | UntypedExpr::Trace { .. } => "{" + UntypedExpr::Sequence { .. } | UntypedExpr::Assignment { .. } => "{" .to_doc() .append(line().append(self.expr(expr)).nest(INDENT)) .append(line()) @@ -1381,9 +1356,7 @@ impl<'comments> Formatter<'comments> { fn case_clause_value<'a>(&mut self, expr: &'a UntypedExpr) -> Document<'a> { match expr { - UntypedExpr::Trace { .. } - | UntypedExpr::Sequence { .. } - | UntypedExpr::Assignment { .. } => " {" + UntypedExpr::Sequence { .. } | UntypedExpr::Assignment { .. } => " {" .to_doc() .append(line().append(self.expr(expr)).nest(INDENT).group()) .append(line()) diff --git a/crates/lang/src/parser.rs b/crates/lang/src/parser.rs index 0a4253ba..03ae4473 100644 --- a/crates/lang/src/parser.rs +++ b/crates/lang/src/parser.rs @@ -553,23 +553,9 @@ pub fn anon_fn_param_parser() -> impl Parser impl Parser { recursive(|r| { - choice(( - just(Token::Trace) - .ignore_then( - select! {Token::String {value} => value} - .delimited_by(just(Token::LeftParen), just(Token::RightParen)) - .or_not(), - ) - .then(r.clone()) - .map_with_span(|(text, then_), span| expr::UntypedExpr::Trace { - location: span, - then: Box::new(then_), - text, - }), - expr_parser(r.clone()) - .then(r.repeated()) - .foldl(|current, next| current.append_in_sequence(next)), - )) + expr_parser(r.clone()) + .then(r.repeated()) + .foldl(|current, next| current.append_in_sequence(next)) }) } diff --git a/crates/lang/src/parser/lexer.rs b/crates/lang/src/parser/lexer.rs index 7256fe36..537c7cff 100644 --- a/crates/lang/src/parser/lexer.rs +++ b/crates/lang/src/parser/lexer.rs @@ -87,7 +87,6 @@ pub fn lexer() -> impl Parser, Error = ParseError> { "pub" => Token::Pub, "use" => Token::Use, "todo" => Token::Todo, - "trace" => Token::Trace, "type" => Token::Type, "when" => Token::When, _ => { diff --git a/crates/lang/src/parser/token.rs b/crates/lang/src/parser/token.rs index 0ed3efac..000076f6 100644 --- a/crates/lang/src/parser/token.rs +++ b/crates/lang/src/parser/token.rs @@ -71,7 +71,6 @@ pub enum Token { Use, Test, Todo, - Trace, Type, When, } @@ -81,7 +80,6 @@ impl fmt::Display for Token { let s = match self { Token::Error(c) => { write!(f, "\"{}\"", c)?; - return Ok(()); } Token::Name { name } => name, @@ -146,7 +144,6 @@ impl fmt::Display for Token { Token::Opaque => "opaque", Token::Pub => "pub", Token::Todo => "todo", - Token::Trace => "try", Token::Type => "type", Token::Test => "test", }; diff --git a/crates/lang/src/tipo/expr.rs b/crates/lang/src/tipo/expr.rs index c9d0a43e..7fb986ff 100644 --- a/crates/lang/src/tipo/expr.rs +++ b/crates/lang/src/tipo/expr.rs @@ -279,8 +279,6 @@ impl<'a, 'b> ExprTyper<'a, 'b> { .. } => self.infer_assignment(pattern, *value, kind, &annotation, location), - UntypedExpr::Trace { location, then, .. } => self.infer_trace(*then, location), - UntypedExpr::When { location, subjects, @@ -1713,19 +1711,6 @@ impl<'a, 'b> ExprTyper<'a, 'b> { } } - fn infer_trace(&mut self, then: UntypedExpr, location: Span) -> Result { - // Check the type of the following code - let then = self.infer(then)?; - - let tipo = then.tipo(); - - Ok(TypedExpr::Trace { - location, - tipo, - then: Box::new(then), - }) - } - fn infer_value_constructor( &mut self, module: &Option, diff --git a/crates/lang/src/tipo/infer.rs b/crates/lang/src/tipo/infer.rs index 1abd2adc..2e5be297 100644 --- a/crates/lang/src/tipo/infer.rs +++ b/crates/lang/src/tipo/infer.rs @@ -474,7 +474,6 @@ fn str_to_keyword(word: &str) -> Option { "opaque" => Some(Token::Opaque), "pub" => Some(Token::Pub), "todo" => Some(Token::Todo), - "try" => Some(Token::Trace), "type" => Some(Token::Type), _ => None, } diff --git a/crates/lang/src/uplc.rs b/crates/lang/src/uplc.rs index 6f79bdcd..27b45b5d 100644 --- a/crates/lang/src/uplc.rs +++ b/crates/lang/src/uplc.rs @@ -283,7 +283,6 @@ impl<'a> CodeGenerator<'a> { ir_stack.append(&mut define_vec); ir_stack.append(&mut pattern_vec); } - TypedExpr::Trace { .. } => todo!(), TypedExpr::When { subjects, clauses, .. } => {