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:
parent
e1f39ae539
commit
c48f15a957
|
@ -7,7 +7,6 @@
|
||||||
- **aiken**: added export command that exporting of regular function definitons. @rvcas
|
- **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 and goto definition support on list tail. @rvcas
|
||||||
- **aiken-lsp**: hover on prop test via expression. @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
|
- **aiken-lang**: new builtin types in the prelude `Pair` and `Pairs`. @KtorZ @Microproofs
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -205,7 +205,6 @@ fn str_to_keyword(word: &str) -> Option<Token> {
|
||||||
"todo" => Some(Token::Todo),
|
"todo" => Some(Token::Todo),
|
||||||
"type" => Some(Token::Type),
|
"type" => Some(Token::Type),
|
||||||
"trace" => Some(Token::Trace),
|
"trace" => Some(Token::Trace),
|
||||||
"emit" => Some(Token::Emit),
|
|
||||||
"test" => Some(Token::Test),
|
"test" => Some(Token::Test),
|
||||||
// TODO: remove this in a future release
|
// TODO: remove this in a future release
|
||||||
"error" => Some(Token::Fail),
|
"error" => Some(Token::Fail),
|
||||||
|
@ -1866,7 +1865,6 @@ pub enum TraceKind {
|
||||||
Trace,
|
Trace,
|
||||||
Todo,
|
Todo,
|
||||||
Error,
|
Error,
|
||||||
Emit,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
@ -2063,7 +2061,7 @@ pub enum Error {
|
||||||
#[diagnostic(code("illegal::module_name"))]
|
#[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):
|
#[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 },
|
KeywordInModuleName { name: String, keyword: String },
|
||||||
|
|
||||||
#[error("I realized you used '{}' as a module name, which is reserved (and not available).\n",
|
#[error("I realized you used '{}' as a module name, which is reserved (and not available).\n",
|
||||||
|
|
|
@ -116,13 +116,6 @@ pub enum TypedExpr {
|
||||||
text: Box<Self>,
|
text: Box<Self>,
|
||||||
},
|
},
|
||||||
|
|
||||||
Emit {
|
|
||||||
location: Span,
|
|
||||||
tipo: Rc<Type>,
|
|
||||||
then: Box<Self>,
|
|
||||||
text: Box<Self>,
|
|
||||||
},
|
|
||||||
|
|
||||||
When {
|
When {
|
||||||
location: Span,
|
location: Span,
|
||||||
tipo: Rc<Type>,
|
tipo: Rc<Type>,
|
||||||
|
@ -210,7 +203,6 @@ impl TypedExpr {
|
||||||
match self {
|
match self {
|
||||||
Self::Var { constructor, .. } => constructor.tipo.clone(),
|
Self::Var { constructor, .. } => constructor.tipo.clone(),
|
||||||
Self::Trace { then, .. } => then.tipo(),
|
Self::Trace { then, .. } => then.tipo(),
|
||||||
Self::Emit { then, .. } => then.tipo(),
|
|
||||||
Self::Fn { tipo, .. }
|
Self::Fn { tipo, .. }
|
||||||
| Self::UInt { tipo, .. }
|
| Self::UInt { tipo, .. }
|
||||||
| Self::ErrorTerm { tipo, .. }
|
| Self::ErrorTerm { tipo, .. }
|
||||||
|
@ -257,7 +249,6 @@ impl TypedExpr {
|
||||||
TypedExpr::Fn { .. }
|
TypedExpr::Fn { .. }
|
||||||
| TypedExpr::UInt { .. }
|
| TypedExpr::UInt { .. }
|
||||||
| TypedExpr::Trace { .. }
|
| TypedExpr::Trace { .. }
|
||||||
| TypedExpr::Emit { .. }
|
|
||||||
| TypedExpr::List { .. }
|
| TypedExpr::List { .. }
|
||||||
| TypedExpr::Call { .. }
|
| TypedExpr::Call { .. }
|
||||||
| TypedExpr::When { .. }
|
| TypedExpr::When { .. }
|
||||||
|
@ -301,7 +292,6 @@ impl TypedExpr {
|
||||||
| Self::UInt { location, .. }
|
| Self::UInt { location, .. }
|
||||||
| Self::Var { location, .. }
|
| Self::Var { location, .. }
|
||||||
| Self::Trace { location, .. }
|
| Self::Trace { location, .. }
|
||||||
| Self::Emit { location, .. }
|
|
||||||
| Self::ErrorTerm { location, .. }
|
| Self::ErrorTerm { location, .. }
|
||||||
| Self::When { location, .. }
|
| Self::When { location, .. }
|
||||||
| Self::Call { location, .. }
|
| Self::Call { location, .. }
|
||||||
|
@ -338,7 +328,6 @@ impl TypedExpr {
|
||||||
Self::Fn { location, .. }
|
Self::Fn { location, .. }
|
||||||
| Self::UInt { location, .. }
|
| Self::UInt { location, .. }
|
||||||
| Self::Trace { location, .. }
|
| Self::Trace { location, .. }
|
||||||
| Self::Emit { location, .. }
|
|
||||||
| Self::Var { location, .. }
|
| Self::Var { location, .. }
|
||||||
| Self::ErrorTerm { location, .. }
|
| Self::ErrorTerm { location, .. }
|
||||||
| Self::When { location, .. }
|
| Self::When { location, .. }
|
||||||
|
@ -383,11 +372,6 @@ impl TypedExpr {
|
||||||
.or_else(|| then.find_node(byte_index))
|
.or_else(|| then.find_node(byte_index))
|
||||||
.or(Some(Located::Expression(self))),
|
.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, .. } => {
|
TypedExpr::Pipeline { expressions, .. } | TypedExpr::Sequence { expressions, .. } => {
|
||||||
expressions.iter().find_map(|e| e.find_node(byte_index))
|
expressions.iter().find_map(|e| e.find_node(byte_index))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1037,7 +1037,6 @@ impl<'comments> Formatter<'comments> {
|
||||||
TraceKind::Trace => ("trace", None),
|
TraceKind::Trace => ("trace", None),
|
||||||
TraceKind::Error => ("fail", Some(DEFAULT_ERROR_STR.to_string())),
|
TraceKind::Error => ("fail", Some(DEFAULT_ERROR_STR.to_string())),
|
||||||
TraceKind::Todo => ("todo", Some(DEFAULT_TODO_STR.to_string())),
|
TraceKind::Todo => ("todo", Some(DEFAULT_TODO_STR.to_string())),
|
||||||
TraceKind::Emit => ("emit", None),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let body = match text {
|
let body = match text {
|
||||||
|
@ -1053,7 +1052,7 @@ impl<'comments> Formatter<'comments> {
|
||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
TraceKind::Error | TraceKind::Todo => body,
|
TraceKind::Error | TraceKind::Todo => body,
|
||||||
TraceKind::Trace | TraceKind::Emit => body
|
TraceKind::Trace => body
|
||||||
.append(if self.pop_empty_lines(then.start_byte_index()) {
|
.append(if self.pop_empty_lines(then.start_byte_index()) {
|
||||||
lines(2)
|
lines(2)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -541,14 +541,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
self.build(then, module_build_name, &[]),
|
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 {
|
TypedExpr::When {
|
||||||
tipo,
|
tipo,
|
||||||
subject,
|
subject,
|
||||||
|
@ -5633,15 +5625,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
Some(term)
|
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, .. } => {
|
Air::ErrorTerm { validator, .. } => {
|
||||||
if validator {
|
if validator {
|
||||||
Some(Term::Error.apply(Term::Error.force()))
|
Some(Term::Error.apply(Term::Error.force()))
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use indexmap::IndexSet;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use uplc::builtins::DefaultFunction;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{BinOp, Curve, UnOp},
|
ast::{BinOp, Curve, UnOp},
|
||||||
tipo::{Type, ValueConstructor},
|
tipo::{Type, ValueConstructor},
|
||||||
};
|
};
|
||||||
|
use indexmap::IndexSet;
|
||||||
|
use std::rc::Rc;
|
||||||
|
use uplc::builtins::DefaultFunction;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Copy)]
|
#[derive(Debug, Clone, PartialEq, Copy)]
|
||||||
pub enum ExpectLevel {
|
pub enum ExpectLevel {
|
||||||
|
@ -221,9 +220,6 @@ pub enum Air {
|
||||||
Trace {
|
Trace {
|
||||||
tipo: Rc<Type>,
|
tipo: Rc<Type>,
|
||||||
},
|
},
|
||||||
Emit {
|
|
||||||
tipo: Rc<Type>,
|
|
||||||
},
|
|
||||||
NoOp,
|
NoOp,
|
||||||
FieldsEmpty,
|
FieldsEmpty,
|
||||||
ListEmpty,
|
ListEmpty,
|
||||||
|
|
|
@ -964,13 +964,6 @@ impl AirTree {
|
||||||
then: then.into(),
|
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 {
|
pub fn no_op(then: AirTree) -> AirTree {
|
||||||
AirTree::NoOp { then: then.into() }
|
AirTree::NoOp { then: then.into() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use chumsky::prelude::*;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::TraceKind,
|
ast::TraceKind,
|
||||||
expr::UntypedExpr,
|
expr::UntypedExpr,
|
||||||
|
@ -9,6 +7,7 @@ use crate::{
|
||||||
token::Token,
|
token::Token,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use chumsky::prelude::*;
|
||||||
|
|
||||||
pub fn parser<'a>(
|
pub fn parser<'a>(
|
||||||
expression: Recursive<'a, Token, UntypedExpr, ParseError>,
|
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))),
|
then: Box::new(then_.unwrap_or_else(|| UntypedExpr::todo(None, span))),
|
||||||
text: Box::new(text),
|
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() {
|
fn trace_expr_todo() {
|
||||||
assert_expr!(
|
assert_expr!(
|
||||||
r#"
|
r#"
|
||||||
trace some_var
|
trace some_var
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
let keyword = text::ident().map(|s: String| match s.as_str() {
|
||||||
"trace" => Token::Trace,
|
"trace" => Token::Trace,
|
||||||
"emit" => Token::Emit,
|
|
||||||
// TODO: remove this in a future release
|
// TODO: remove this in a future release
|
||||||
"error" => Token::Fail,
|
"error" => Token::Fail,
|
||||||
"fail" => Token::Fail,
|
"fail" => Token::Fail,
|
||||||
|
|
|
@ -89,7 +89,6 @@ pub enum Token {
|
||||||
Type,
|
Type,
|
||||||
When,
|
When,
|
||||||
Trace,
|
Trace,
|
||||||
Emit,
|
|
||||||
Validator,
|
Validator,
|
||||||
Via,
|
Via,
|
||||||
}
|
}
|
||||||
|
@ -176,7 +175,6 @@ impl fmt::Display for Token {
|
||||||
Token::Pub => "pub",
|
Token::Pub => "pub",
|
||||||
Token::Todo => "todo",
|
Token::Todo => "todo",
|
||||||
Token::Trace => "trace",
|
Token::Trace => "trace",
|
||||||
Token::Emit => "emit",
|
|
||||||
Token::Type => "type",
|
Token::Type => "type",
|
||||||
Token::Test => "test",
|
Token::Test => "test",
|
||||||
Token::Fail => "fail",
|
Token::Fail => "fail",
|
||||||
|
|
|
@ -1098,7 +1098,6 @@ impl TryFrom<TypedExpr> for Assertion<TypedExpr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedExpr::Trace { then, .. } => (*then).try_into(),
|
TypedExpr::Trace { then, .. } => (*then).try_into(),
|
||||||
TypedExpr::Emit { then, .. } => (*then).try_into(),
|
|
||||||
|
|
||||||
TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => {
|
TypedExpr::Sequence { expressions, .. } | TypedExpr::Pipeline { expressions, .. } => {
|
||||||
if let Ok(Assertion {
|
if let Ok(Assertion {
|
||||||
|
|
Loading…
Reference in New Issue