revert #903 'feat: Emit keyword'

While we agree on the idea of having some ways of emitting events, the
  design hasn't been completely fleshed out and it is unclear whether
  events should have a well-defined format independent of the framework
  / compiler and what this format should be.

  So we need more time discussing and agreeing about what use case we
  are actually trying to solve with that.

  Irrespective of that, some cleanup was also needed on the UPLC side
  anyway since the PR introduced a lot of needless duplications.
This commit is contained in:
KtorZ 2024-05-23 17:22:12 +02:00
parent e1f39ae539
commit c48f15a957
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
11 changed files with 7 additions and 69 deletions

View File

@ -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

View File

@ -205,7 +205,6 @@ fn str_to_keyword(word: &str) -> Option<Token> {
"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",

View File

@ -116,13 +116,6 @@ pub enum TypedExpr {
text: Box<Self>,
},
Emit {
location: Span,
tipo: Rc<Type>,
then: Box<Self>,
text: Box<Self>,
},
When {
location: Span,
tipo: Rc<Type>,
@ -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))
}

View File

@ -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 {

View File

@ -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()))

View File

@ -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<Type>,
},
Emit {
tipo: Rc<Type>,
},
NoOp,
FieldsEmpty,
ListEmpty,

View File

@ -964,13 +964,6 @@ impl AirTree {
then: then.into(),
}
}
pub fn emit(msg: AirTree, tipo: Rc<Type>, then: AirTree) -> AirTree {
AirTree::Trace {
tipo,
msg: msg.into(),
then: then.into(),
}
}
pub fn no_op(then: AirTree) -> AirTree {
AirTree::NoOp { then: then.into() }
}

View File

@ -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
"#
);
}

View File

@ -220,7 +220,6 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, 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,

View File

@ -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",

View File

@ -1098,7 +1098,6 @@ impl TryFrom<TypedExpr> for Assertion<TypedExpr> {
}
TypedExpr::Trace { then, .. } => (*then).try_into(),
TypedExpr::Emit { then, .. } => (*then).try_into(),
TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => {
if let Ok(Assertion {