diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e00830b..f582db03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ - **aiken**: added export command that exporting of regular function definitons. @rvcas - **aiken-lsp**: hover and goto definition support on list tail. @rvcas - **aiken-lsp**: hover on prop test via expression. @rvcas -- **aiken-lang**: a new way to emit logs that don't get erased. @micahkendall - **aiken-lang**: new builtin types in the prelude `Pair` and `Pairs`. @KtorZ @Microproofs ### Fixed diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 714fa210..d4e2d6ec 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -205,7 +205,6 @@ fn str_to_keyword(word: &str) -> Option { "todo" => Some(Token::Todo), "type" => Some(Token::Type), "trace" => Some(Token::Trace), - "emit" => Some(Token::Emit), "test" => Some(Token::Test), // TODO: remove this in a future release "error" => Some(Token::Fail), @@ -1866,7 +1865,6 @@ pub enum TraceKind { Trace, Todo, Error, - Emit, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -2063,7 +2061,7 @@ pub enum Error { #[diagnostic(code("illegal::module_name"))] #[diagnostic(help(r#"You cannot use keywords as part of a module path name. As a quick reminder, here's a list of all the keywords (and thus, of invalid module path names): - as, expect, check, const, else, fn, if, is, let, opaque, pub, test, todo, trace, emit, type, use, when"#))] + as, expect, check, const, else, fn, if, is, let, opaque, pub, test, todo, trace, type, use, when"#))] KeywordInModuleName { name: String, keyword: String }, #[error("I realized you used '{}' as a module name, which is reserved (and not available).\n", diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index 961adb5f..e519b425 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -116,13 +116,6 @@ pub enum TypedExpr { text: Box, }, - Emit { - location: Span, - tipo: Rc, - then: Box, - text: Box, - }, - When { location: Span, tipo: Rc, @@ -210,7 +203,6 @@ impl TypedExpr { match self { Self::Var { constructor, .. } => constructor.tipo.clone(), Self::Trace { then, .. } => then.tipo(), - Self::Emit { then, .. } => then.tipo(), Self::Fn { tipo, .. } | Self::UInt { tipo, .. } | Self::ErrorTerm { tipo, .. } @@ -257,7 +249,6 @@ impl TypedExpr { TypedExpr::Fn { .. } | TypedExpr::UInt { .. } | TypedExpr::Trace { .. } - | TypedExpr::Emit { .. } | TypedExpr::List { .. } | TypedExpr::Call { .. } | TypedExpr::When { .. } @@ -301,7 +292,6 @@ impl TypedExpr { | Self::UInt { location, .. } | Self::Var { location, .. } | Self::Trace { location, .. } - | Self::Emit { location, .. } | Self::ErrorTerm { location, .. } | Self::When { location, .. } | Self::Call { location, .. } @@ -338,7 +328,6 @@ impl TypedExpr { Self::Fn { location, .. } | Self::UInt { location, .. } | Self::Trace { location, .. } - | Self::Emit { location, .. } | Self::Var { location, .. } | Self::ErrorTerm { location, .. } | Self::When { location, .. } @@ -383,11 +372,6 @@ impl TypedExpr { .or_else(|| then.find_node(byte_index)) .or(Some(Located::Expression(self))), - TypedExpr::Emit { text, then, .. } => text - .find_node(byte_index) - .or_else(|| then.find_node(byte_index)) - .or(Some(Located::Expression(self))), - TypedExpr::Pipeline { expressions, .. } | TypedExpr::Sequence { expressions, .. } => { expressions.iter().find_map(|e| e.find_node(byte_index)) } diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index 938c3024..f2a1af28 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -1037,7 +1037,6 @@ impl<'comments> Formatter<'comments> { TraceKind::Trace => ("trace", None), TraceKind::Error => ("fail", Some(DEFAULT_ERROR_STR.to_string())), TraceKind::Todo => ("todo", Some(DEFAULT_TODO_STR.to_string())), - TraceKind::Emit => ("emit", None), }; let body = match text { @@ -1053,7 +1052,7 @@ impl<'comments> Formatter<'comments> { match kind { TraceKind::Error | TraceKind::Todo => body, - TraceKind::Trace | TraceKind::Emit => body + TraceKind::Trace => body .append(if self.pop_empty_lines(then.start_byte_index()) { lines(2) } else { diff --git a/crates/aiken-lang/src/gen_uplc.rs b/crates/aiken-lang/src/gen_uplc.rs index 68047ee7..f6ee5c03 100644 --- a/crates/aiken-lang/src/gen_uplc.rs +++ b/crates/aiken-lang/src/gen_uplc.rs @@ -541,14 +541,6 @@ impl<'a> CodeGenerator<'a> { self.build(then, module_build_name, &[]), ), - TypedExpr::Emit { - tipo, then, text, .. - } => AirTree::emit( - self.build(text, module_build_name, &[]), - tipo.clone(), - self.build(then, module_build_name, &[]), - ), - TypedExpr::When { tipo, subject, @@ -5633,15 +5625,6 @@ impl<'a> CodeGenerator<'a> { Some(term) } - Air::Emit { .. } => { - let text = arg_stack.pop().unwrap(); - - let term = arg_stack.pop().unwrap(); - - let term = term.delayed_trace(text); - - Some(term) - } Air::ErrorTerm { validator, .. } => { if validator { Some(Term::Error.apply(Term::Error.force())) diff --git a/crates/aiken-lang/src/gen_uplc/air.rs b/crates/aiken-lang/src/gen_uplc/air.rs index 74acc6bd..a3df8503 100644 --- a/crates/aiken-lang/src/gen_uplc/air.rs +++ b/crates/aiken-lang/src/gen_uplc/air.rs @@ -1,11 +1,10 @@ -use indexmap::IndexSet; -use std::rc::Rc; -use uplc::builtins::DefaultFunction; - use crate::{ ast::{BinOp, Curve, UnOp}, tipo::{Type, ValueConstructor}, }; +use indexmap::IndexSet; +use std::rc::Rc; +use uplc::builtins::DefaultFunction; #[derive(Debug, Clone, PartialEq, Copy)] pub enum ExpectLevel { @@ -221,9 +220,6 @@ pub enum Air { Trace { tipo: Rc, }, - Emit { - tipo: Rc, - }, NoOp, FieldsEmpty, ListEmpty, diff --git a/crates/aiken-lang/src/gen_uplc/tree.rs b/crates/aiken-lang/src/gen_uplc/tree.rs index 8de60875..de07950f 100644 --- a/crates/aiken-lang/src/gen_uplc/tree.rs +++ b/crates/aiken-lang/src/gen_uplc/tree.rs @@ -964,13 +964,6 @@ impl AirTree { then: then.into(), } } - pub fn emit(msg: AirTree, tipo: Rc, then: AirTree) -> AirTree { - AirTree::Trace { - tipo, - msg: msg.into(), - then: then.into(), - } - } pub fn no_op(then: AirTree) -> AirTree { AirTree::NoOp { then: then.into() } } diff --git a/crates/aiken-lang/src/parser/expr/fail_todo_trace.rs b/crates/aiken-lang/src/parser/expr/fail_todo_trace.rs index 96d23b7e..618daaae 100644 --- a/crates/aiken-lang/src/parser/expr/fail_todo_trace.rs +++ b/crates/aiken-lang/src/parser/expr/fail_todo_trace.rs @@ -1,5 +1,3 @@ -use chumsky::prelude::*; - use crate::{ ast::TraceKind, expr::UntypedExpr, @@ -9,6 +7,7 @@ use crate::{ token::Token, }, }; +use chumsky::prelude::*; pub fn parser<'a>( expression: Recursive<'a, Token, UntypedExpr, ParseError>, @@ -36,15 +35,6 @@ pub fn parser<'a>( then: Box::new(then_.unwrap_or_else(|| UntypedExpr::todo(None, span))), text: Box::new(text), }), - just(Token::Emit) - .ignore_then(choice((string::hybrid(), expression.clone()))) - .then(sequence.clone().or_not()) - .map_with_span(|(text, then_), span| UntypedExpr::Trace { - kind: TraceKind::Emit, - location: span, - then: Box::new(then_.unwrap_or_else(|| UntypedExpr::todo(None, span))), - text: Box::new(text), - }), )) } @@ -138,7 +128,7 @@ mod tests { fn trace_expr_todo() { assert_expr!( r#" - trace some_var + trace some_var "# ); } diff --git a/crates/aiken-lang/src/parser/lexer.rs b/crates/aiken-lang/src/parser/lexer.rs index c9bed8ba..c1fc1282 100644 --- a/crates/aiken-lang/src/parser/lexer.rs +++ b/crates/aiken-lang/src/parser/lexer.rs @@ -220,7 +220,6 @@ pub fn lexer() -> impl Parser, Error = ParseError> { let keyword = text::ident().map(|s: String| match s.as_str() { "trace" => Token::Trace, - "emit" => Token::Emit, // TODO: remove this in a future release "error" => Token::Fail, "fail" => Token::Fail, diff --git a/crates/aiken-lang/src/parser/token.rs b/crates/aiken-lang/src/parser/token.rs index 04c821df..6169749f 100644 --- a/crates/aiken-lang/src/parser/token.rs +++ b/crates/aiken-lang/src/parser/token.rs @@ -89,7 +89,6 @@ pub enum Token { Type, When, Trace, - Emit, Validator, Via, } @@ -176,7 +175,6 @@ impl fmt::Display for Token { Token::Pub => "pub", Token::Todo => "todo", Token::Trace => "trace", - Token::Emit => "emit", Token::Type => "type", Token::Test => "test", Token::Fail => "fail", diff --git a/crates/aiken-project/src/test_framework.rs b/crates/aiken-project/src/test_framework.rs index b3e44052..43ba4bfe 100644 --- a/crates/aiken-project/src/test_framework.rs +++ b/crates/aiken-project/src/test_framework.rs @@ -1098,7 +1098,6 @@ impl TryFrom for Assertion { } TypedExpr::Trace { then, .. } => (*then).try_into(), - TypedExpr::Emit { then, .. } => (*then).try_into(), TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => { if let Ok(Assertion {