Rename console.assert* to assert*. (#2205)

* Add assert statements to AST

* Add support in passes

* Add parser support

* Add tyc support

* Add support for assert statements in the remaining passes

* Fix examples, tests, and regen expectations

* Fmt

* Regen expectations
This commit is contained in:
d0cd 2022-12-06 21:56:48 -08:00 committed by GitHub
parent 3c21fd446e
commit 48a1f0590b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 642 additions and 421 deletions

View File

@ -70,6 +70,7 @@ pub trait StatementConsumer {
fn consume_statement(&mut self, input: Statement) -> Self::Output {
match input {
Statement::Assert(assert) => self.consume_assert(assert),
Statement::Assign(stmt) => self.consume_assign(*stmt),
Statement::Block(stmt) => self.consume_block(stmt),
Statement::Conditional(stmt) => self.consume_conditional(stmt),
@ -83,6 +84,8 @@ pub trait StatementConsumer {
}
}
fn consume_assert(&mut self, input: AssertStatement) -> Self::Output;
fn consume_assign(&mut self, input: AssignStatement) -> Self::Output;
fn consume_block(&mut self, input: Block) -> Self::Output;

View File

@ -161,6 +161,7 @@ pub trait ExpressionReconstructor {
pub trait StatementReconstructor: ExpressionReconstructor {
fn reconstruct_statement(&mut self, input: Statement) -> (Statement, Self::AdditionalOutput) {
match input {
Statement::Assert(assert) => self.reconstruct_assert(assert),
Statement::Assign(stmt) => self.reconstruct_assign(*stmt),
Statement::Block(stmt) => {
let (stmt, output) = self.reconstruct_block(stmt);
@ -177,6 +178,26 @@ pub trait StatementReconstructor: ExpressionReconstructor {
}
}
fn reconstruct_assert(&mut self, input: AssertStatement) -> (Statement, Self::AdditionalOutput) {
(
Statement::Assert(AssertStatement {
variant: match input.variant {
AssertVariant::Assert(expr) => AssertVariant::Assert(self.reconstruct_expression(expr).0),
AssertVariant::AssertEq(left, right) => AssertVariant::AssertEq(
self.reconstruct_expression(left).0,
self.reconstruct_expression(right).0,
),
AssertVariant::AssertNeq(left, right) => AssertVariant::AssertNeq(
self.reconstruct_expression(left).0,
self.reconstruct_expression(right).0,
),
},
span: input.span,
}),
Default::default(),
)
}
fn reconstruct_assign(&mut self, input: AssignStatement) -> (Statement, Self::AdditionalOutput) {
(
Statement::Assign(Box::new(AssignStatement {

View File

@ -117,6 +117,7 @@ pub trait ExpressionVisitor<'a> {
pub trait StatementVisitor<'a>: ExpressionVisitor<'a> {
fn visit_statement(&mut self, input: &'a Statement) {
match input {
Statement::Assert(stmt) => self.visit_assert(stmt),
Statement::Assign(stmt) => self.visit_assign(stmt),
Statement::Block(stmt) => self.visit_block(stmt),
Statement::Conditional(stmt) => self.visit_conditional(stmt),
@ -130,6 +131,16 @@ pub trait StatementVisitor<'a>: ExpressionVisitor<'a> {
}
}
fn visit_assert(&mut self, input: &'a AssertStatement) {
match &input.variant {
AssertVariant::Assert(expr) => self.visit_expression(expr, &Default::default()),
AssertVariant::AssertEq(left, right) | AssertVariant::AssertNeq(left, right) => {
self.visit_expression(left, &Default::default());
self.visit_expression(right, &Default::default())
}
};
}
fn visit_assign(&mut self, input: &'a AssignStatement) {
self.visit_expression(&input.value, &Default::default());
}

View File

@ -0,0 +1,54 @@
// Copyright (C) 2019-2022 Aleo Systems Inc.
// This file is part of the Leo library.
// The Leo library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// The Leo library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{Expression, Node};
use leo_span::Span;
use serde::{Deserialize, Serialize};
use std::fmt;
/// A variant of an assert statement.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum AssertVariant {
/// A `assert(expr)` variant, asserting that the expression evaluates to true.
Assert(Expression),
/// A `assert_eq(expr1, expr2)` variant, asserting that the operands are equal.
AssertEq(Expression, Expression),
/// A `assert_neq(expr1, expr2)` variant, asserting that the operands are not equal.
AssertNeq(Expression, Expression),
}
/// An assert statement, `assert(<expr>)`, `assert_eq(<expr>)` or `assert_neq(<expr>)`.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub struct AssertStatement {
/// The variant of the assert statement.
pub variant: AssertVariant,
/// The span, excluding the semicolon.
pub span: Span,
}
impl fmt::Display for AssertStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.variant {
AssertVariant::Assert(ref expr) => write!(f, "assert({expr});"),
AssertVariant::AssertEq(ref expr1, ref expr2) => write!(f, "assert_eq({expr1}, {expr2});"),
AssertVariant::AssertNeq(ref expr1, ref expr2) => write!(f, "assert_neq({expr1}, {expr2});"),
}
}
}
crate::simple_node_impl!(AssertStatement);

View File

@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
pub mod assert;
pub use assert::*;
pub mod assign;
pub use assign::*;
@ -54,6 +57,8 @@ use std::fmt;
/// Program statement that defines some action (or expression) to be carried out.
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum Statement {
/// An assert statement.
Assert(AssertStatement),
/// An assignment statement.
Assign(Box<AssignStatement>),
/// A block statement.
@ -89,6 +94,7 @@ impl Statement {
impl fmt::Display for Statement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Statement::Assert(x) => x.fmt(f),
Statement::Assign(x) => x.fmt(f),
Statement::Block(x) => x.fmt(f),
Statement::Conditional(x) => x.fmt(f),
@ -107,6 +113,7 @@ impl Node for Statement {
fn span(&self) -> Span {
use Statement::*;
match self {
Assert(n) => n.span(),
Assign(n) => n.span(),
Block(n) => n.span(),
Conditional(n) => n.span(),
@ -123,6 +130,7 @@ impl Node for Statement {
fn set_span(&mut self, span: Span) {
use Statement::*;
match self {
Assert(n) => n.set_span(span),
Assign(n) => n.set_span(span),
Block(n) => n.set_span(span),
Conditional(n) => n.set_span(span),

View File

@ -45,16 +45,50 @@ impl ParserContext<'_> {
Token::Decrement => Ok(Statement::Decrement(self.parse_decrement_statement()?)),
Token::If => Ok(Statement::Conditional(self.parse_conditional_statement()?)),
Token::For => Ok(Statement::Iteration(Box::new(self.parse_loop_statement()?))),
Token::Console => Ok(Statement::Console(self.parse_console_statement()?)),
Token::Assert | Token::AssertEq | Token::AssertNeq => Ok(self.parse_assert_statement()?),
Token::Let | Token::Const => Ok(Statement::Definition(self.parse_definition_statement()?)),
Token::LeftCurly => Ok(Statement::Block(self.parse_block()?)),
Token::Async => Err(ParserError::async_finalize_is_deprecated(self.token.span).into()),
Token::Console => Err(ParserError::console_statements_are_not_yet_supported(self.token.span).into()),
Token::Finalize => Err(ParserError::finalize_statements_are_deprecated(self.token.span).into()),
_ => Ok(self.parse_assign_statement()?),
}
}
/// Returns a [`Block`] AST node if the next tokens represent a assign, or expression statement.
/// Returns a [`AssertStatement`] AST node if the next tokens represent an assertion statement.
fn parse_assert_statement(&mut self) -> Result<Statement> {
// Check which variant of the assert statement is being used.
// Note that `parse_assert_statement` is called only if the next token is an assertion token.
let is_assert = self.check(&Token::Assert);
let is_assert_eq = self.check(&Token::AssertEq);
let is_assert_neq = self.check(&Token::AssertNeq);
// Parse the span of the assertion statement.
let span = self.expect_any(&[Token::Assert, Token::AssertEq, Token::AssertNeq])?;
// Parse the left parenthesis token.
self.expect(&Token::LeftParen)?;
// Parse the variant.
let variant = match (is_assert, is_assert_eq, is_assert_neq) {
(true, false, false) => AssertVariant::Assert(self.parse_expression()?),
(false, true, false) => AssertVariant::AssertEq(self.parse_expression()?, {
self.expect(&Token::Comma)?;
self.parse_expression()?
}),
(false, false, true) => AssertVariant::AssertNeq(self.parse_expression()?, {
self.expect(&Token::Comma)?;
self.parse_expression()?
}),
_ => unreachable!("The call the `expect_any` ensures that only one of the three tokens is true."),
};
// Parse the right parenthesis token.
self.expect(&Token::RightParen)?;
// Parse the semicolon token.
self.expect(&Token::Semicolon)?;
// Return the assertion statement.
Ok(Statement::Assert(AssertStatement { variant, span }))
}
/// Returns a [`AssignStatement`] AST node if the next tokens represent a assign, otherwise expects an expression statement.
fn parse_assign_statement(&mut self) -> Result<Statement> {
let place = self.parse_expression()?;
@ -246,6 +280,7 @@ impl ParserContext<'_> {
}
/// Returns a [`ConsoleStatement`] AST node if the next tokens represent a console statement.
#[allow(dead_code)]
fn parse_console_statement(&mut self) -> Result<ConsoleStatement> {
let keyword = self.expect(&Token::Console)?;
self.expect(&Token::Dot)?;

View File

@ -394,6 +394,9 @@ impl Token {
match &*identifier {
x if x.starts_with("aleo1") => Token::AddressLit(identifier),
"address" => Token::Address,
"assert" => Token::Assert,
"assert_eq" => Token::AssertEq,
"assert_neq" => Token::AssertNeq,
"async" => Token::Async,
"bool" => Token::Bool,
"circuit" => Token::Circuit,

View File

@ -83,6 +83,9 @@ mod tests {
test_ident
12345
address
assert
assert_eq
assert_neq
async
bool
const
@ -164,7 +167,7 @@ mod tests {
assert_eq!(
output,
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in input let mut private program public return scalar self string struct test then transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" test_ident 12345 address assert assert_eq assert_neq async bool const else false field finalize for function group i128 i64 i32 i16 i8 if in input let mut private program public return scalar self string struct test then transition true u128 u64 u32 u16 u8 console ! != && ( ) * ** + , - -> => _ . .. / : ; < <= = == > >= [ ] { { } } || ? @ // test
/* test */ // "#
);
});

View File

@ -108,6 +108,9 @@ pub enum Token {
Record,
// Regular Keywords
Assert,
AssertEq,
AssertNeq,
Async,
Circuit,
Console,
@ -149,6 +152,9 @@ pub enum Token {
/// because true and false are also boolean literals, which are different tokens from keywords
pub const KEYWORD_TOKENS: &[Token] = &[
Token::Address,
Token::Assert,
Token::AssertEq,
Token::AssertNeq,
Token::Async,
Token::Bool,
Token::Console,
@ -203,6 +209,9 @@ impl Token {
pub fn keyword_to_symbol(&self) -> Option<Symbol> {
Some(match self {
Token::Address => sym::address,
Token::Assert => sym::assert,
Token::AssertEq => sym::assert_eq,
Token::AssertNeq => sym::assert_neq,
Token::Async => sym::Async,
Token::Bool => sym::bool,
Token::Console => sym::console,
@ -335,6 +344,9 @@ impl fmt::Display for Token {
U128 => write!(f, "u128"),
Record => write!(f, "record"),
Assert => write!(f, "assert"),
AssertEq => write!(f, "assert_eq"),
AssertNeq => write!(f, "assert_neq"),
Async => write!(f, "async"),
Circuit => write!(f, "circuit"),
Console => write!(f, "console"),

View File

@ -96,10 +96,7 @@ impl<'a> CodeGenerator<'a> {
};
let destination_register = format!("r{}", self.next_register);
let binary_instruction = format!(
" {} {} {} into {};\n",
opcode, left_operand, right_operand, destination_register
);
let binary_instruction = format!(" {opcode} {left_operand} {right_operand} into {destination_register};\n",);
// Increment the register counter.
self.next_register += 1;
@ -146,8 +143,7 @@ impl<'a> CodeGenerator<'a> {
let destination_register = format!("r{}", self.next_register);
let ternary_instruction = format!(
" ternary {} {} {} into {};\n",
condition_operand, if_true_operand, if_false_operand, destination_register
" ternary {condition_operand} {if_true_operand} {if_false_operand} into {destination_register};\n",
);
// Increment the register counter.
@ -202,13 +198,8 @@ impl<'a> CodeGenerator<'a> {
// Push destination register to struct init instruction.
let destination_register = format!("r{}", self.next_register);
writeln!(
struct_init_instruction,
"into {dest} as {name};",
dest = destination_register,
name = name,
)
.expect("failed to write to string");
writeln!(struct_init_instruction, "into {destination_register} as {name};",)
.expect("failed to write to string");
instructions.push_str(&struct_init_instruction);
@ -319,8 +310,7 @@ impl<'a> CodeGenerator<'a> {
self.next_register += 1;
}
let destinations = destinations.join(" ");
writeln!(call_instruction, " into {destinations};", destinations = destinations)
.expect("failed to write to string");
writeln!(call_instruction, " into {destinations};").expect("failed to write to string");
instructions.push_str(&call_instruction);
(destinations, instructions)

View File

@ -17,7 +17,7 @@
use crate::CodeGenerator;
use leo_ast::{
AssignStatement, Block, ConditionalStatement, ConsoleFunction, ConsoleStatement, DecrementStatement,
AssertStatement, AssertVariant, AssignStatement, Block, ConditionalStatement, ConsoleStatement, DecrementStatement,
DefinitionStatement, Expression, ExpressionStatement, IncrementStatement, IterationStatement, Mode, Output,
ReturnStatement, Statement,
};
@ -28,6 +28,7 @@ use std::fmt::Write as _;
impl<'a> CodeGenerator<'a> {
fn visit_statement(&mut self, input: &'a Statement) -> String {
match input {
Statement::Assert(stmt) => self.visit_assert(stmt),
Statement::Assign(stmt) => self.visit_assign(stmt),
Statement::Block(stmt) => self.visit_block(stmt),
Statement::Conditional(stmt) => self.visit_conditional(stmt),
@ -41,6 +42,32 @@ impl<'a> CodeGenerator<'a> {
}
}
fn visit_assert(&mut self, input: &'a AssertStatement) -> String {
let mut generate_assert_instruction = |name: &str, left: &'a Expression, right: &'a Expression| {
let (left_operand, left_instructions) = self.visit_expression(left);
let (right_operand, right_instructions) = self.visit_expression(right);
let assert_instruction = format!(" {name} {left_operand} {right_operand};\n");
// Concatenate the instructions.
let mut instructions = left_instructions;
instructions.push_str(&right_instructions);
instructions.push_str(&assert_instruction);
instructions
};
match &input.variant {
AssertVariant::Assert(expr) => {
let (operand, mut instructions) = self.visit_expression(expr);
let assert_instruction = format!(" assert.eq {operand} true;\n");
instructions.push_str(&assert_instruction);
instructions
}
AssertVariant::AssertEq(left, right) => generate_assert_instruction("assert.eq", left, right),
AssertVariant::AssertNeq(left, right) => generate_assert_instruction("assert.neq", left, right),
}
}
fn visit_return(&mut self, input: &'a ReturnStatement) -> String {
let mut instructions = match input.expression {
// Skip empty return statements.
@ -108,7 +135,7 @@ impl<'a> CodeGenerator<'a> {
for argument in arguments.iter() {
let (argument, argument_instructions) = self.visit_expression(argument);
write!(finalize_instruction, " {}", argument).expect("failed to write to string");
write!(finalize_instruction, " {argument}").expect("failed to write to string");
instructions.push_str(&argument_instructions);
}
writeln!(finalize_instruction, ";").expect("failed to write to string");
@ -195,30 +222,8 @@ impl<'a> CodeGenerator<'a> {
unreachable!("`IterationStatement`s should not be in the AST at this phase of compilation.");
}
fn visit_console(&mut self, input: &'a ConsoleStatement) -> String {
let mut generate_assert_instruction = |name: &str, left: &'a Expression, right: &'a Expression| {
let (left_operand, left_instructions) = self.visit_expression(left);
let (right_operand, right_instructions) = self.visit_expression(right);
let assert_instruction = format!(" {name} {left_operand} {right_operand};\n");
// Concatenate the instructions.
let mut instructions = left_instructions;
instructions.push_str(&right_instructions);
instructions.push_str(&assert_instruction);
instructions
};
match &input.function {
ConsoleFunction::Assert(expr) => {
let (operand, mut instructions) = self.visit_expression(expr);
let assert_instruction = format!(" assert.eq {operand} true;\n");
instructions.push_str(&assert_instruction);
instructions
}
ConsoleFunction::AssertEq(left, right) => generate_assert_instruction("assert.eq", left, right),
ConsoleFunction::AssertNeq(left, right) => generate_assert_instruction("assert.neq", left, right),
}
fn visit_console(&mut self, _: &'a ConsoleStatement) -> String {
unreachable!("Parsing guarantees that `ConsoleStatement`s are not present in the AST.")
}
pub(crate) fn visit_block(&mut self, input: &'a Block) -> String {

View File

@ -19,12 +19,102 @@ use itertools::Itertools;
use std::borrow::Borrow;
use leo_ast::{
AssignStatement, BinaryExpression, BinaryOperation, Block, ConditionalStatement, ConsoleFunction, ConsoleStatement,
DefinitionStatement, Expression, ExpressionReconstructor, Identifier, IterationStatement, Node, ReturnStatement,
Statement, StatementReconstructor, TupleExpression, Type, UnaryExpression, UnaryOperation,
AssertStatement, AssertVariant, AssignStatement, BinaryExpression, BinaryOperation, Block, ConditionalStatement,
ConsoleStatement, DefinitionStatement, Expression, ExpressionReconstructor, Identifier, IterationStatement, Node,
ReturnStatement, Statement, StatementReconstructor, TupleExpression, Type, UnaryExpression, UnaryOperation,
};
impl StatementReconstructor for Flattener<'_> {
/// Rewrites an assert statement into a flattened form.
/// Assert statements at the top level only have their arguments flattened.
/// Assert statements inside a conditional statement are flattened to such that the check is conditional on
/// the execution path being valid.
/// For example, the following snippet:
/// ```leo
/// if condition1 {
/// if condition2 {
/// assert(foo);
/// }
/// }
/// ```
/// is flattened to:
/// ```leo
/// assert(!(condition1 && condition2) || foo);
/// ```
/// which is equivalent to the logical formula `(condition1 /\ condition2) ==> foo`.
fn reconstruct_assert(&mut self, input: AssertStatement) -> (Statement, Self::AdditionalOutput) {
let mut statements = Vec::new();
// Flatten the arguments of the assert statement.
let assert = AssertStatement {
span: input.span,
variant: match input.variant {
AssertVariant::Assert(expression) => {
let (expression, additional_statements) = self.reconstruct_expression(expression);
statements.extend(additional_statements);
AssertVariant::Assert(expression)
}
AssertVariant::AssertEq(left, right) => {
let (left, additional_statements) = self.reconstruct_expression(left);
statements.extend(additional_statements);
let (right, additional_statements) = self.reconstruct_expression(right);
statements.extend(additional_statements);
AssertVariant::AssertEq(left, right)
}
AssertVariant::AssertNeq(left, right) => {
let (left, additional_statements) = self.reconstruct_expression(left);
statements.extend(additional_statements);
let (right, additional_statements) = self.reconstruct_expression(right);
statements.extend(additional_statements);
AssertVariant::AssertNeq(left, right)
}
},
};
// Add the appropriate guards.
match self.construct_guard() {
// If the condition stack is empty, we can return the flattened assert statement.
None => (Statement::Assert(assert), statements),
// Otherwise, we need to join the guard with the expression in the flattened assert statement.
// Note given the guard and the expression, we construct the logical formula `guard => expression`,
// which is equivalent to `!guard || expression`.
Some(guard) => (
Statement::Assert(AssertStatement {
span: input.span,
variant: AssertVariant::Assert(Expression::Binary(BinaryExpression {
// Take the logical negation of the guard.
left: Box::new(Expression::Unary(UnaryExpression {
op: UnaryOperation::Not,
receiver: Box::new(guard),
span: Default::default(),
})),
op: BinaryOperation::Or,
span: Default::default(),
right: Box::new(match assert.variant {
// If the assert statement is an `assert`, use the expression as is.
AssertVariant::Assert(expression) => expression,
// If the assert statement is an `assert_eq`, construct a new equality expression.
AssertVariant::AssertEq(left, right) => Expression::Binary(BinaryExpression {
left: Box::new(left),
op: BinaryOperation::Eq,
right: Box::new(right),
span: Default::default(),
}),
// If the assert statement is an `assert_ne`, construct a new inequality expression.
AssertVariant::AssertNeq(left, right) => Expression::Binary(BinaryExpression {
left: Box::new(left),
op: BinaryOperation::Neq,
right: Box::new(right),
span: Default::default(),
}),
}),
})),
}),
statements,
),
}
}
/// Flattens an assign statement, if necessary.
/// Marks variables as structs as necessary.
/// Note that new statements are only produced if the right hand side is a ternary expression over structs.
@ -272,94 +362,8 @@ impl StatementReconstructor for Flattener<'_> {
(Statement::dummy(Default::default()), statements)
}
/// Rewrites a console statement into a flattened form.
/// Console statements at the top level only have their arguments flattened.
/// Console statements inside a conditional statement are flattened to such that the check is conditional on
/// the execution path being valid.
/// For example, the following snippet:
/// ```leo
/// if condition1 {
/// if condition2 {
/// console.assert(foo);
/// }
/// }
/// ```
/// is flattened to:
/// ```leo
/// console.assert(!(condition1 && condition2) || foo);
/// ```
/// which is equivalent to the logical formula `(condition1 /\ condition2) ==> foo`.
fn reconstruct_console(&mut self, input: ConsoleStatement) -> (Statement, Self::AdditionalOutput) {
let mut statements = Vec::new();
// Flatten the arguments of the console statement.
let console = ConsoleStatement {
span: input.span,
function: match input.function {
ConsoleFunction::Assert(expression) => {
let (expression, additional_statements) = self.reconstruct_expression(expression);
statements.extend(additional_statements);
ConsoleFunction::Assert(expression)
}
ConsoleFunction::AssertEq(left, right) => {
let (left, additional_statements) = self.reconstruct_expression(left);
statements.extend(additional_statements);
let (right, additional_statements) = self.reconstruct_expression(right);
statements.extend(additional_statements);
ConsoleFunction::AssertEq(left, right)
}
ConsoleFunction::AssertNeq(left, right) => {
let (left, additional_statements) = self.reconstruct_expression(left);
statements.extend(additional_statements);
let (right, additional_statements) = self.reconstruct_expression(right);
statements.extend(additional_statements);
ConsoleFunction::AssertNeq(left, right)
}
},
};
// Add the appropriate guards.
match self.construct_guard() {
// If the condition stack is empty, we can return the flattened console statement.
None => (Statement::Console(console), statements),
// Otherwise, we need to join the guard with the expression in the flattened console statement.
// Note given the guard and the expression, we construct the logical formula `guard => expression`,
// which is equivalent to `!guard || expression`.
Some(guard) => (
Statement::Console(ConsoleStatement {
span: input.span,
function: ConsoleFunction::Assert(Expression::Binary(BinaryExpression {
// Take the logical negation of the guard.
left: Box::new(Expression::Unary(UnaryExpression {
op: UnaryOperation::Not,
receiver: Box::new(guard),
span: Default::default(),
})),
op: BinaryOperation::Or,
span: Default::default(),
right: Box::new(match console.function {
// If the console statement is an `assert`, use the expression as is.
ConsoleFunction::Assert(expression) => expression,
// If the console statement is an `assert_eq`, construct a new equality expression.
ConsoleFunction::AssertEq(left, right) => Expression::Binary(BinaryExpression {
left: Box::new(left),
op: BinaryOperation::Eq,
right: Box::new(right),
span: Default::default(),
}),
// If the console statement is an `assert_ne`, construct a new inequality expression.
ConsoleFunction::AssertNeq(left, right) => Expression::Binary(BinaryExpression {
left: Box::new(left),
op: BinaryOperation::Neq,
right: Box::new(right),
span: Default::default(),
}),
}),
})),
}),
statements,
),
}
fn reconstruct_console(&mut self, _: ConsoleStatement) -> (Statement, Self::AdditionalOutput) {
unreachable!("`ConsoleStatement`s should not be in the AST at this phase of compilation.")
}
/// Static single assignment converts definition statements into assignment statements.

View File

@ -17,7 +17,7 @@
use crate::{RenameTable, StaticSingleAssigner};
use leo_ast::{
AssignStatement, Block, CallExpression, ConditionalStatement, ConsoleFunction, ConsoleStatement,
AssertStatement, AssertVariant, AssignStatement, Block, CallExpression, ConditionalStatement, ConsoleStatement,
DecrementStatement, DefinitionStatement, Expression, ExpressionConsumer, ExpressionStatement, Identifier,
IncrementStatement, IterationStatement, ReturnStatement, Statement, StatementConsumer, TernaryExpression,
TupleExpression,
@ -29,6 +29,44 @@ use indexmap::IndexSet;
impl StatementConsumer for StaticSingleAssigner<'_> {
type Output = Vec<Statement>;
/// Consumes the expressions in an `AssertStatement`, returning the list of simplified statements.
fn consume_assert(&mut self, input: AssertStatement) -> Self::Output {
let (variant, mut statements) = match input.variant {
AssertVariant::Assert(expr) => {
let (expr, statements) = self.consume_expression(expr);
(AssertVariant::Assert(expr), statements)
}
AssertVariant::AssertEq(left, right) => {
// Reconstruct the lhs of the binary expression.
let (left, mut statements) = self.consume_expression(left);
// Reconstruct the rhs of the binary expression.
let (right, right_statements) = self.consume_expression(right);
// Accumulate any statements produced.
statements.extend(right_statements);
(AssertVariant::AssertEq(left, right), statements)
}
AssertVariant::AssertNeq(left, right) => {
// Reconstruct the lhs of the binary expression.
let (left, mut statements) = self.consume_expression(left);
// Reconstruct the rhs of the binary expression.
let (right, right_statements) = self.consume_expression(right);
// Accumulate any statements produced.
statements.extend(right_statements);
(AssertVariant::AssertNeq(left, right), statements)
}
};
// Add the assert statement to the list of produced statements.
statements.push(Statement::Assert(AssertStatement {
variant,
span: input.span,
}));
statements
}
/// Consume all `AssignStatement`s, renaming as necessary.
fn consume_assign(&mut self, assign: AssignStatement) -> Self::Output {
// First consume the right-hand-side of the assignment.
@ -160,41 +198,8 @@ impl StatementConsumer for StaticSingleAssigner<'_> {
}
/// Consumes the expressions in a `ConsoleStatement`, returning the list of simplified statements.
fn consume_console(&mut self, input: ConsoleStatement) -> Self::Output {
let (function, mut statements) = match input.function {
ConsoleFunction::Assert(expr) => {
let (expr, statements) = self.consume_expression(expr);
(ConsoleFunction::Assert(expr), statements)
}
ConsoleFunction::AssertEq(left, right) => {
// Reconstruct the lhs of the binary expression.
let (left, mut statements) = self.consume_expression(left);
// Reconstruct the rhs of the binary expression.
let (right, right_statements) = self.consume_expression(right);
// Accumulate any statements produced.
statements.extend(right_statements);
(ConsoleFunction::AssertEq(left, right), statements)
}
ConsoleFunction::AssertNeq(left, right) => {
// Reconstruct the lhs of the binary expression.
let (left, mut statements) = self.consume_expression(left);
// Reconstruct the rhs of the binary expression.
let (right, right_statements) = self.consume_expression(right);
// Accumulate any statements produced.
statements.extend(right_statements);
(ConsoleFunction::AssertNeq(left, right), statements)
}
};
// Add the console statement to the list of produced statements.
statements.push(Statement::Console(ConsoleStatement {
function,
span: input.span,
}));
statements
fn consume_console(&mut self, _: ConsoleStatement) -> Self::Output {
unreachable!("Parsing guarantees that console statements are not present in the program.")
}
/// Consumes the expressions associated with the `DecrementStatement`, returning the simplified `DecrementStatement`.

View File

@ -30,6 +30,7 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
}
match input {
Statement::Assert(stmt) => self.visit_assert(stmt),
Statement::Assign(stmt) => self.visit_assign(stmt),
Statement::Block(stmt) => self.visit_block(stmt),
Statement::Conditional(stmt) => self.visit_conditional(stmt),
@ -43,6 +44,22 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
}
}
fn visit_assert(&mut self, input: &'a AssertStatement) {
match &input.variant {
AssertVariant::Assert(expr) => {
let type_ = self.visit_expression(expr, &Some(Type::Boolean));
self.assert_bool_type(&type_, expr.span());
}
AssertVariant::AssertEq(left, right) | AssertVariant::AssertNeq(left, right) => {
let t1 = self.visit_expression(left, &None);
let t2 = self.visit_expression(right, &None);
// Check that the types are equal.
self.check_eq_types(&t1, &t2, input.span());
}
}
}
fn visit_assign(&mut self, input: &'a AssignStatement) {
let var_name = match input.place {
Expression::Identifier(id) => id,
@ -131,20 +148,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
self.has_finalize = previous_has_finalize || (then_block_has_finalize && otherwise_block_has_finalize);
}
fn visit_console(&mut self, input: &'a ConsoleStatement) {
match &input.function {
ConsoleFunction::Assert(expr) => {
let type_ = self.visit_expression(expr, &Some(Type::Boolean));
self.assert_bool_type(&type_, expr.span());
}
ConsoleFunction::AssertEq(left, right) | ConsoleFunction::AssertNeq(left, right) => {
let t1 = self.visit_expression(left, &None);
let t2 = self.visit_expression(right, &None);
// Check that the types are equal.
self.check_eq_types(&t1, &t2, input.span());
}
}
fn visit_console(&mut self, _: &'a ConsoleStatement) {
unreachable!("Parsing guarantees that console statements are not present in the AST.");
}
fn visit_decrement(&mut self, input: &'a DecrementStatement) {

View File

@ -181,6 +181,8 @@ symbols! {
// general keywords
AlwaysConst,
assert,
assert_eq,
assert_neq,
Async: "async",
caller,
circuit,
@ -200,8 +202,6 @@ symbols! {
input,
Let: "let",
leo,
assert_eq,
assert_neq,
main,
mapping,
Mut: "mut",

View File

@ -134,10 +134,8 @@ impl fmt::Display for Backtraced {
if let Some(help) = &self.help {
write!(
f,
"\n{indent } |\n\
{indent } = {help}",
indent = INDENT,
help = help
"\n{INDENT } |\n\
{INDENT } = {help}",
)?;
}

View File

@ -164,20 +164,13 @@ impl fmt::Display for Formatted {
)?;
}
write!(
f,
"{indent } |{underlined}",
indent = INDENT,
underlined = underlined,
)?;
write!(f, "{INDENT } |{underlined}",)?;
if let Some(help) = &self.backtrace.help {
write!(
f,
"\n{indent } |\n\
{indent } = {help}",
indent = INDENT,
help = help
"\n{INDENT } |\n\
{INDENT } = {help}",
)?;
}

View File

@ -276,4 +276,11 @@ create_messages!(
msg: format!("`finalize` statements are deprecated."),
help: Some("Use `return <expr> then finalize(<args>)` instead.".to_string()),
}
@formatted
console_statements_are_not_yet_supported {
args: (),
msg: format!("`console` statements are not yet supported."),
help: Some("Consider using `assert`, `assert_eq`, or `assert_neq` instead.".to_string()),
}
);

View File

@ -29,7 +29,7 @@ The auction is conducted in a series of stages.
## Language Features and Concepts
- `record` declarations
- `console.assert_eq`
- `assert_eq`
- record ownership
## Running the Program

View File

@ -22,7 +22,7 @@ program auction.aleo {
// The address of the auction runner is aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.
transition place_bid(bidder: address, amount: u64) -> Bid {
// Ensure the caller is the auction bidder.
console.assert_eq(self.caller, bidder);
assert_eq(self.caller, bidder);
// Return a new 'Bid' record for the auction bidder.
return Bid {
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh,
@ -41,7 +41,7 @@ program auction.aleo {
// In the event of a tie, the first bid is selected.
transition resolve(first: Bid, second: Bid) -> Bid {
// Ensure the caller is the auctioneer.
console.assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh);
assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh);
// Resolve the winner of the auction.
if (first.amount >= second.amount) {
return first;
@ -56,7 +56,7 @@ program auction.aleo {
// Assumes that the function is invoked only after all bids have been resolved.
transition finish(bid: Bid) -> Bid {
// Ensure the caller is the auctioneer.
console.assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh);
assert_eq(self.caller, aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh);
// Return 'is_winner' as 'true' in the winning 'Bid'.
return Bid {
owner: bid.bidder,

View File

@ -26,7 +26,7 @@ Can you find any others?
## Language Features and Concepts
- `record` declarations
- `console.assert_eq`
- `assert_eq`
- core functions, e.g. `BHP256::hash`
- record ownership
- loops and bounded iteration

View File

@ -19,7 +19,7 @@ program basic_bank.aleo {
// Requires that the function caller is the bank.
// The bank's address is aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a.
transition issue(owner: address, amount: u64) -> Token {
console.assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a);
assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a);
return Token {
owner: owner,
gates: 0u64,
@ -60,7 +60,7 @@ program basic_bank.aleo {
// - `periods` : The number of periods to compound the interest over.
// Requires that the function caller is the bank.
transition withdraw(recipient: address, amount: u64, rate: u64, periods: u64) -> Token {
console.assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a);
assert_eq(self.caller, aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a);
let hash: field = BHP256::hash(recipient);
let total: u64 = calculate_interest(amount, rate, periods);

View File

@ -44,7 +44,7 @@ program board.aleo {
board: board_state,
) -> board_state {
// Ensure this board hasn't been used to start a game before.
console.assert(!board.game_started);
assert(!board.game_started);
return board_state {
owner: board.owner,
@ -70,11 +70,11 @@ program board.aleo {
let flip_bit: u64 = shoot - 1u64;
// bitwise and operation
let check_move: u64 = shoot & flip_bit;
console.assert_eq(check_move, 0u64);
assert_eq(check_move, 0u64);
// Need to make sure r1 is a valid move given the played_tiles. no bits should overlap.
let check_tiles: u64 = shoot & board.played_tiles;
console.assert_eq(check_tiles, 0u64);
assert_eq(check_tiles, 0u64);
// Update played tiles.
let played_tiles: u64 = board.played_tiles | shoot;

View File

@ -87,7 +87,7 @@ program verify.aleo {
) -> bool {
// Check bitcount -- all other validations depend on the bitcount being correct.
let num_bits: u64 = bitcount(ship);
console.assert_eq(num_bits, length);
assert_eq(num_bits, length);
// Check horizontal bits of ship.
let is_adjacent: bool = adjacency_check(ship, horizontal); // True if bits are adjacent horizontally.
@ -118,7 +118,7 @@ program verify.aleo {
let ships: u64 = carrier | battleship | cruiser | destroyer;
let num_bits: u64 = bitcount(ships);
console.assert_eq(num_bits, 14u64); // Given 4 individually-valid ships, a valid combination should yield exactly 14 flipped bits.
assert_eq(num_bits, 14u64); // Given 4 individually-valid ships, a valid combination should yield exactly 14 flipped bits.
return ships;
}

View File

@ -19,16 +19,16 @@ program battleship.aleo {
) -> board.leo/board_state.record {
// Verify that each individual ship placement bitstring is valid.
let valid_carrier: bool = verify.leo/validate_ship(carrier, 5u64, 31u64, 4311810305u64);
console.assert(valid_carrier);
assert(valid_carrier);
let valid_battleship: bool = verify.leo/validate_ship(battleship, 4u64, 15u64, 16843009u64);
console.assert(valid_battleship);
assert(valid_battleship);
let valid_cruiser: bool = verify.leo/validate_ship(cruiser, 3u64, 7u64, 65793u64);
console.assert(valid_cruiser);
assert(valid_cruiser);
let valid_destroyer: bool = verify.leo/validate_ship(destroyer, 2u64, 3u64, 257u64);
console.assert(valid_destroyer);
assert(valid_destroyer);
// Create the board with all the ship placements combined.
let board: u64 = verify.leo/create_board(carrier, battleship, cruiser, destroyer);
@ -61,8 +61,8 @@ program battleship.aleo {
move_start: move.leo/move.record,
) -> (board.leo/board_state.record, move.leo/move.record) {
// Validate that the move players and board players match each other.
console.assert_eq(board.player_1, move_start.player_2);
console.assert_eq(board.player_2, move_start.player_1);
assert_eq(board.player_1, move_start.player_2);
assert_eq(board.player_2, move_start.player_1);
let state: board_state = board.leo/start_board(board);
let dummy: move = move.leo/start_game(board.player_2);
@ -82,11 +82,11 @@ program battleship.aleo {
) -> (board.leo/board_state.record, move.leo/move.record) {
// Verify the board has been started. This prevents players from starting a game and then creating
// a brand new board to play with.
console.assert(board.game_started);
assert(board.game_started);
// Validate that the move players and board players match each other.
console.assert_eq(board.player_1, move_incoming.player_2);
console.assert_eq(board.player_2, move_incoming.player_1);
assert_eq(board.player_1, move_incoming.player_2);
assert_eq(board.player_2, move_incoming.player_1);
// Play coordinate on own board. Will fail if not a valid move.
let hit_or_miss: board_state = board.leo/update_played_tiles(board, shoot);

View File

@ -1,7 +1,7 @@
program fibonacci.aleo {
// This calculates the n-th fibonacci number (up to 64th)
transition fibonacci(public n: u8) -> u128 {
console.assert(n <= 64u8);
assert(n <= 64u8);
let f0: u128 = 0u128;
let f1: u128 = 1u128;

View File

@ -18,7 +18,7 @@ program interest.aleo {
transition bounded_iteration_interest(capital: u32,
public rate: u32,
iterations: u8) -> u32 {
console.assert(iterations <= 50u8);
assert(iterations <= 50u8);
let amount: u32 = capital;
// Accrue for up to 50 iterations.

View File

@ -56,9 +56,9 @@ program tictactoe.aleo {
// If an entry is already occupied, the move is invalid and the board is returned unchanged.
transition make_move(player: u8, row: u8, col: u8, board: Board) -> (Board, u8) {
// Check that inputs are valid.
console.assert(player == 1u8 || player == 2u8);
console.assert(1u8 <= row && row <= 3u8);
console.assert(1u8 <= col && col <= 3u8);
assert(player == 1u8 || player == 2u8);
assert(1u8 <= row && row <= 3u8);
assert(1u8 <= col && col <= 3u8);
// Unpack the entries in the board into variables.
let r1c1: u8 = board.r1.c1;

View File

@ -35,7 +35,7 @@ program vote.aleo {
// Propose a new proposal to vote on.
transition propose(public info: ProposalInfo) -> Proposal {
// Authenticate proposer.
console.assert_eq(self.caller, info.proposer);
assert_eq(self.caller, info.proposer);
// Generate a new proposal id.
let id: field = BHP256::hash(info.title);

View File

@ -20,13 +20,13 @@ program test.aleo {
transition main(a: bool, foo: Foo, token: Token) -> bool {
console.assert_eq(a, true);
console.assert_neq(a, false);
console.assert(a);
assert_eq(a, true);
assert_neq(a, false);
assert(a);
console.assert_eq(foo, Foo { a: 0u8 });
assert_eq(foo, Foo { a: 0u8 });
console.assert_neq(token, Token {
assert_neq(token, Token {
owner: aleo1lfapwg53y5enqpt0d8cnef4g8lj7l6g9uhkkma23qyv6jm4ppyfq50regr,
gates: 0u64,
amount: 0u64,

View File

@ -7,8 +7,8 @@ input_file: inputs/true.in
program test.aleo {
transition main(a: bool) -> bool {
console.assert_eq(a == 1u8);
console.assert(1u8);
assert_eq(a == 1u8);
assert(1u8);
return a == true;
}

View File

@ -9,7 +9,7 @@ program test.aleo {
return true;
}
if (id_type == 2u8) {
console.assert(0u8 > id_type);
assert(0u8 > id_type);
return false;
}
return false;

View File

@ -6,7 +6,7 @@ input_file: inputs/three.in
program test.aleo {
transition main(a: group, b: group, c: group) -> bool {
console.assert(a + b == c);
assert(a + b == c);
return a + b == c;
}}

View File

@ -6,6 +6,6 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: group, b: group) -> bool {
console.assert(a == b);
assert(a == b);
return a == b;
}}

View File

@ -6,6 +6,6 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: group, b: group) -> bool {
console.assert(a == b);
assert(a == b);
return a == b;
}}

View File

@ -6,6 +6,6 @@ input_file: inputs/dummy.in
program test.aleo {
transition main(a: group, b: group) -> bool {
console.assert(a == b);
assert(a == b);
return a == b;
}}

View File

@ -6,7 +6,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: group, b: group) -> bool {
console.assert(-a == b);
assert(-a == b);
return -a == b;
}}

View File

@ -6,7 +6,7 @@ input_file: inputs/three.in
program test.aleo {
transition main(a: group, b: group, c: group) -> bool {
console.assert(a - b == c);
assert(a - b == c);
return a - b == c;
}}

View File

@ -8,6 +8,6 @@ program test.aleo {
transition main(a: group, b: group, c: group) -> bool {
const r: group = true ? a : b;
console.assert(r == c);
assert(r == c);
return r == c;
}}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: i128, b: i128) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: i16, b: i16) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: i32, b: i32) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: i64, b: i64) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: i8, b: i8) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: u128, b: u128) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: u16, b: u16) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: u32, b: u32) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: u64, b: u64) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -7,7 +7,7 @@ input_file: inputs/eq.in
program test.aleo {
transition main(a: u8, b: u8) -> bool {
let ret: bool = a == b;
console.assert(ret);
assert(ret);
return ret;
}
}

View File

@ -6,7 +6,7 @@ expectation: Pass
program test.aleo {
function foo(a: u8, b: u8) -> () {
console.assert_eq(a, b);
assert_eq(a, b);
}
transition main(a: u8, b: u8) -> u8 {

View File

@ -5,7 +5,7 @@ expectation: Fail
program test.aleo {
function foo(a: ()) -> u8 {
console.assert_eq(1u8, 2u8);
assert_eq(1u8, 2u8);
return 3u8;
}

View File

@ -6,36 +6,36 @@ expectation: Pass
program test.aleo {
transition foo(a: u8, b: u8) -> () {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
return ();
}
transition bar(a: u8, b: u8) -> () {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
return;
}
transition baz(a: u8, b: u8) -> () {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
}
transition floo(a: u8, b: u8) {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
return ();
}
transition blar(a: u8, b: u8) {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
return;
}
transition blaz(a: u8, b: u8) {
console.assert_eq(a, b);
console.assert_eq(b, a);
assert_eq(a, b);
assert_eq(b, a);
}
}

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: e7874e1d569eadaa5313be245f71202463aef0100ae21305a8212812f2881555
initial_ast: 3a6f935c5ca129da9caece4c27c5c32b7b8588fab4ee6f7446ef88b41f13e2a6
unrolled_ast: 3a6f935c5ca129da9caece4c27c5c32b7b8588fab4ee6f7446ef88b41f13e2a6
ssa_ast: 6c3f28ee2ba2a54c325e82bfa0c1ca032f16cb5d86e70f376d3185adc9a07578
flattened_ast: 45cc072f14c0bb07ef7e78e7973aee0ebaf767a3921f13e62065eb40b7ae3960
- initial_input_ast: 641018618502e5639dffe558a8e6e6b2f7270c0edcc54ce18e3ae529d76466f0
initial_ast: 4e20619777361f8912d710acf353032dd188b059f692f48e3c158a80a9da363a
unrolled_ast: 4e20619777361f8912d710acf353032dd188b059f692f48e3c158a80a9da363a
ssa_ast: 766a9c926f389deb5c355324f0cb6dc2b541b0b2076f4b255e7797f13862690f
flattened_ast: 55195378adbdbd0cf8f7f2274731f60d15935a55c0eead0e42e80900feece741

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [EPAR0370005]: expected , -- found ')'\n --> compiler-test:6:35\n |\n 6 | console.assert_eq(a == 1u8);\n | ^"
- "Error [EPAR0370005]: expected , -- found ')'\n --> compiler-test:6:27\n |\n 6 | assert_eq(a == 1u8);\n | ^"

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: no input
initial_ast: 8a02943ec06fdce6dbaa8629e3d69a2f6aabaa62af4379cd38bf05336e5b33f3
unrolled_ast: 8a02943ec06fdce6dbaa8629e3d69a2f6aabaa62af4379cd38bf05336e5b33f3
ssa_ast: ef8e0d6155b97f72a62f02038d180cfa251de925d2d2fbce410db7a560d77231
flattened_ast: ae328dab873969a1194a18b519934915927d6d5fa1d190f6d74f8d4ad3c8c89a
initial_ast: c61a7b3e47fd17204c11b4310b596b82e020e6723a8cde15e27cbb253e370861
unrolled_ast: c61a7b3e47fd17204c11b4310b596b82e020e6723a8cde15e27cbb253e370861
ssa_ast: 99b0120939ef940955fa931a5abc7ead3e2e140ede12ea9298dcb13a1c65ca00
flattened_ast: 53e7c22a21b128656ac2f7910120b4c0dd78df39fef84462ada4c4a48cd29768

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> compiler-test:5:17\n |\n 5 | console.log(\"{}\", 1u8);\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> compiler-test:5:20\n |\n 5 | console.log(\"{}\", 1u8);\n | ^"
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> compiler-test:5:9\n |\n 5 | console.log(\"{}\", 1u8);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> compiler-test:5:17\n |\n 5 | console.log(\"{}\", 1u8);\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> compiler-test:5:20\n |\n 5 | console.log(\"{}\", 1u8);\n | ^"
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> compiler-test:5:9\n |\n 5 | console.log(\"{}\", 1u8);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 24452096d9adcaa859a76f761fb9abdc61400486eaf37d62a77c6e2896c77afb
initial_ast: db4d6c45319c9d110a370a27a5cddf8f6c47a83fa0f785e36cf60d86edd9a3f2
unrolled_ast: db4d6c45319c9d110a370a27a5cddf8f6c47a83fa0f785e36cf60d86edd9a3f2
ssa_ast: 845dda94bb6db83627618bf4103870115460eb549b6881b9922315624dc93905
flattened_ast: 356c83c7783c4147e511f7754db74d54a674129675ca761f4316e3eaa45b9d96
- initial_input_ast: 285049ab9ae60b75286e1bd1abd3c2343053cf43e393cfe7588fe91e464ab030
initial_ast: 751676152069e8c016aa9183838f5daae994359c43d24bc3eae0e4aaacf4e662
unrolled_ast: 751676152069e8c016aa9183838f5daae994359c43d24bc3eae0e4aaacf4e662
ssa_ast: 7bac7ca4e9212f01e500e2e13540da3cfc6be5c69fba697964ee13111830cc0d
flattened_ast: e236d5dafeca9c94722bc1c3cb3e940637ea5a07d43d7ec27450e40db2bc8816

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 3797d2bdbc9f4815d1ef88b8becca656f3840b170094ddbb1bdfade4d8e567a1
initial_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
unrolled_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
ssa_ast: 419ae5ce3ad3092e27bc5c4edcc0036c044e9b7976de8d722b9af0784379042e
flattened_ast: d6e6d1b1020e0102ef00ba895ce4560798c983965f36e27496fc3f23537ac0a9
- initial_input_ast: 75d04615c39809f20616867728af983eb4b583c16ac6648f78dce0827e559b83
initial_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
unrolled_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
ssa_ast: d559b759fca7b7ebe0fcbdb2e9649f936dd35ed27a9775da4f67d384776a81df
flattened_ast: 85f04590c532e0a43ce9cee7092e516f23ed4313463c14cac6e3a0be52ebf686

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 3797d2bdbc9f4815d1ef88b8becca656f3840b170094ddbb1bdfade4d8e567a1
initial_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
unrolled_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
ssa_ast: 419ae5ce3ad3092e27bc5c4edcc0036c044e9b7976de8d722b9af0784379042e
flattened_ast: d6e6d1b1020e0102ef00ba895ce4560798c983965f36e27496fc3f23537ac0a9
- initial_input_ast: 75d04615c39809f20616867728af983eb4b583c16ac6648f78dce0827e559b83
initial_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
unrolled_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
ssa_ast: d559b759fca7b7ebe0fcbdb2e9649f936dd35ed27a9775da4f67d384776a81df
flattened_ast: 85f04590c532e0a43ce9cee7092e516f23ed4313463c14cac6e3a0be52ebf686

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 4d621b6b23f3eba436c7e0131354e4a260b8a98e15914e752c4839d7f5c4d25c
initial_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
unrolled_ast: 57ff3d335cb0583f22172636c81c415de383b507fe6b17b8a894551a91deee0d
ssa_ast: 419ae5ce3ad3092e27bc5c4edcc0036c044e9b7976de8d722b9af0784379042e
flattened_ast: d6e6d1b1020e0102ef00ba895ce4560798c983965f36e27496fc3f23537ac0a9
- initial_input_ast: 15d9ca44adc7b4cc6e3dd7a867cc93f3854738fb9709f956ca38d07ee6d253b9
initial_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
unrolled_ast: 3ff51b6ab6c73afc89f345f7e4d03766e36725df127367cc8a42e9743da48d9a
ssa_ast: d559b759fca7b7ebe0fcbdb2e9649f936dd35ed27a9775da4f67d384776a81df
flattened_ast: 85f04590c532e0a43ce9cee7092e516f23ed4313463c14cac6e3a0be52ebf686

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 1abe61a3267b558b08f1911f02c0845d05f7480beda9f84ee7111785e465cd15
initial_ast: 033e2f9fcabfc61279492afd3e58fa88182095b62b4dec2754121254d3add393
unrolled_ast: 033e2f9fcabfc61279492afd3e58fa88182095b62b4dec2754121254d3add393
ssa_ast: c50d671af3ba4cc2963955005bb8a222c2b3c0ae61d81e73f9700041d44e0944
flattened_ast: dcd4d56f5a3ca387732df40629789e5dc98d42e2b3bd5f81f76c60ff879950ba
- initial_input_ast: 89b0eb2dd72a472493aa47cfcabae7f95e060b7a15799e318eebd6f58e3d7b6c
initial_ast: 0de9606035fb31746e652f2a102f88709920988a1e66dbb36f8b350f4f698a77
unrolled_ast: 0de9606035fb31746e652f2a102f88709920988a1e66dbb36f8b350f4f698a77
ssa_ast: 905a419601fefa66c7685f50e21e899b76cb4bed0a82caf92eff1ce730a5a4e1
flattened_ast: b19ffc0329f485162ef291fa1b7c911111563aa0fa4cc138c8bfbe971e31d2a3

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 24452096d9adcaa859a76f761fb9abdc61400486eaf37d62a77c6e2896c77afb
initial_ast: 84c69d911ad27595825890d692e23baa7b8a3ec929ab8431258953e8d83949a1
unrolled_ast: 84c69d911ad27595825890d692e23baa7b8a3ec929ab8431258953e8d83949a1
ssa_ast: efc4991e5d1e7e29437863fbc7208a18eac63370e275314e8f692b04215e7ed7
flattened_ast: 37a45240392c362d284c8fedbd50354c3746dfb25b6d3508b90cdd4689b00616
- initial_input_ast: 285049ab9ae60b75286e1bd1abd3c2343053cf43e393cfe7588fe91e464ab030
initial_ast: bcb54be29902b3a6a9ab0c576f03d8fd1f33e19a1695ac32572a82434cc16a12
unrolled_ast: bcb54be29902b3a6a9ab0c576f03d8fd1f33e19a1695ac32572a82434cc16a12
ssa_ast: 169017050d48d0f83133577d17a53487f8a7dc4e641412935b33bd1bb014f288
flattened_ast: 88b400d71a3cc2b8e1e270ceb8c578f98d5168294bcf9b035881a8dbb8fa1d5f

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 15dd8fc332c05446df0418990c17c417db37437307b4993fb0d857550b28c11b
initial_ast: dd1920e99d57a8b5210f30644580bac5f36c6f1d6f2c4f83054272011ae4d2ef
unrolled_ast: dd1920e99d57a8b5210f30644580bac5f36c6f1d6f2c4f83054272011ae4d2ef
ssa_ast: 934ec2c0619255ead6fdc3c84668e96c0f5b5224383f98f88b4cbd71e51fec69
flattened_ast: c0200d3876e154022fa6339adccf266694aeed5d5f9c292d32cbbabdd5ab38fc
- initial_input_ast: c6205386b10ab879f795ee4468a6c0484b532e647806d9c4525bb2758e60520d
initial_ast: 3ab3d217d44424f3c9303c77e0a37eb26abd63ff49930379f6a1f02a024ae6da
unrolled_ast: 3ab3d217d44424f3c9303c77e0a37eb26abd63ff49930379f6a1f02a024ae6da
ssa_ast: a2811183f6fc214b39a6ff8b6e1de4455d59672e9254f791cdb6b8ac14de05dc
flattened_ast: 2d819fc8c31f65d4c1b5b2dbd771cf1faaf6deab054c2d0a388bff2008166768

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: fd948adbdd5de687a000a2ba4ba163a28b51ae5ddc1f4bb8afabadb3c0a0fc65
initial_ast: cecce7a937f57c01cae63719f6641fb4b60f5a05d03f065b56ffb38c7e717562
unrolled_ast: cecce7a937f57c01cae63719f6641fb4b60f5a05d03f065b56ffb38c7e717562
ssa_ast: 91c237c937a45f979257a2b6f56681a32087a526f3413a539502d02a4440b8e9
flattened_ast: 20ab533f815a69150dfcc7e0fdd69c2e27fb8b1e41d254faf62584ff7c76dc64
- initial_input_ast: 8b871eace746da208e7869964f81dbeb9476a4ff7c7139fb1c89fc91f65cbdbd
initial_ast: 15cd85eb5febc05ec30c69056631c4bc533e1d820f5d62a4b7481d97a4931acf
unrolled_ast: 15cd85eb5febc05ec30c69056631c4bc533e1d820f5d62a4b7481d97a4931acf
ssa_ast: 0bcb1d7cce99a9c367d9e317aac7dc447a5d3b9531185313c58cbdc984b9cf28
flattened_ast: 1216731f0e2781e5e517147ea201eedc69acda757de5def6a5570100bc8eefdb

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 83b0d0ce22e667751ae91281a8dfd1291f8d1d823f5f740b2bd6abce5dbd26c3
initial_ast: 5c3364ca498fe29210b1ebf5371cbfbb454c66127b46e1ce4411a95551c3ab01
unrolled_ast: 5c3364ca498fe29210b1ebf5371cbfbb454c66127b46e1ce4411a95551c3ab01
ssa_ast: ccdd2097aa1638782bf3f04ef174f5d05465177cf3e4f62d61da11ddff0f4eee
flattened_ast: 437efdec3954942355bba351c879f4e86dcf20d1037bf993b4c3a7ec88b32557
- initial_input_ast: 070f1e971f3584cce63592d69bce349eb2bdc2af9bc70f22f0de0399e0cea69f
initial_ast: 74eda21a429b0f0ba817a6ce853939610f2dbe452499bf5f954c989d892e9b57
unrolled_ast: 74eda21a429b0f0ba817a6ce853939610f2dbe452499bf5f954c989d892e9b57
ssa_ast: ab51d6f425b88eb4c1e2337d8ccb14518159aea80c815c5e29cd3842efa4903a
flattened_ast: 00a6cbb9a03ebd04821c15f8ae4e255acd3295d2ac32be108f7f11dd87473263

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: d5eff5d89b59fc926cbe281d3ce9562965b96a8492cb120e6f257aa8e0cc129a
initial_ast: 6ee0d2680f21d9ab049b43524e7b1ba24fc4bf41dbdc112037866abbc58f3516
unrolled_ast: 6ee0d2680f21d9ab049b43524e7b1ba24fc4bf41dbdc112037866abbc58f3516
ssa_ast: 76cf43395b3a235ed21c58e8895f8f80f71a6a122561506f21665fad88c9c0d4
flattened_ast: b57c4cc9218889b6c23a8d307a93e92ba0a2ef9a59291b62bae171c5e147bebd
- initial_input_ast: 0ef396b2e737279a03405d017f876b555987d052f41fe08ff926679664e4c416
initial_ast: 0fa16b421d31181c64d827eb0cc26803afb50f775559db0c1cad61aa731d2b29
unrolled_ast: 0fa16b421d31181c64d827eb0cc26803afb50f775559db0c1cad61aa731d2b29
ssa_ast: d0508856ec89c91fff1009083473827dc06a570f02e7322a3de00dc7a4cf0dd6
flattened_ast: 74181d73dbf00d37dd2b76aafb972297a62d839d20fb29e823fa49094f5727e0

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 255e901028eebc10b8653b7bb448553de33ad2357bd21186d5f345583c09851a
initial_ast: 0b63441885b5948e86085bdb6560b0246a0dedda5dc63093e79c25c1b9ace91d
unrolled_ast: 0b63441885b5948e86085bdb6560b0246a0dedda5dc63093e79c25c1b9ace91d
ssa_ast: bdb449a16972b1854a3543c3222daabedf3f8ccf112c837433817261d55a0189
flattened_ast: 74dc8b734a59124a935cb83b0661aab51e91b06c9e1886d7d5cc8bda1a536b81
- initial_input_ast: 6fff0ac2d8ea250bb41f5d3622e2ab7b2af1693c4fc408c2665f18adaae890f6
initial_ast: fdc6b3ce9649566957303ffdf18e30e6af41a823a494d1e2f6f8854737eca8d0
unrolled_ast: fdc6b3ce9649566957303ffdf18e30e6af41a823a494d1e2f6f8854737eca8d0
ssa_ast: 1cef30a65693810294ed9369ff622b107c25f52dc286653e3dfb26b40cb47890
flattened_ast: e2661a1dbc7dcac1ed4a1ea6e72bab02fbcb238fd0c0515a9989e049ef111413

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 9548e64af3d1801b57e671b887e2a45630155c589bd3f3cba4553d110c72297c
initial_ast: 2d58a494194288fed080c39755574a6f3be47b80a3afad722c10c47c49a1706e
unrolled_ast: 2d58a494194288fed080c39755574a6f3be47b80a3afad722c10c47c49a1706e
ssa_ast: b30507a6851703cb1509ec5cc21928cf6a95e4c7aac420688c939a429fe65064
flattened_ast: ab1d20d5275b7553875510ba847bdd6d93ecb1b0471a6c40564e55814fff48ef
- initial_input_ast: 32e8221f548064e427a86bf3d4c787ef65ad150033e545c4b7af451d1afbac5a
initial_ast: 6607a3ae690e9cc721a138af05d6d7194caeffea05da357f4280233bb8866579
unrolled_ast: 6607a3ae690e9cc721a138af05d6d7194caeffea05da357f4280233bb8866579
ssa_ast: a687cb73337fe1f4777a1e0c8d13e97e82228de64456787d54d616adc1373d7b
flattened_ast: bded7d76b624366a2d1b7d668a78468920a34f551231bbf02205500a9878330f

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 0584ff1e138fd43a9ade570fa63665dad9dba5bc976e90f896f8bd6cfe4f5b6b
initial_ast: 61b0c434711f2e6b03515c76263467e6404425654406be6587f9156f53f415ef
unrolled_ast: 61b0c434711f2e6b03515c76263467e6404425654406be6587f9156f53f415ef
ssa_ast: 686d9513bde6b16cf3206b138784843488894bd836f1358904315e7232084f49
flattened_ast: fe15cb45a3b05f352aa5646776f50f6381dc3671f269f4ada68ec107d9328c61
- initial_input_ast: 823f2466ed751ce2c12a30132f178f48ec56dfb4373c3e73462fcbbc8a212f0c
initial_ast: 3afb21f8db956f1c9b48569a684d1539addb9b0e47b26768a6a699302edef357
unrolled_ast: 3afb21f8db956f1c9b48569a684d1539addb9b0e47b26768a6a699302edef357
ssa_ast: 467768d1b2d13c5b41745d606d166744fc7dfa821fcdff208a296c46713360af
flattened_ast: 9a8f244c166579737aec1b02a70b735bdb61b81f5fce7e6deda64d9b56258466

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: a8703727412fbfb964692a72d1a98edf66f4077d1c0b16616eca3b6b90386014
initial_ast: b164f33a2444d2ed798cce895b69dd2bf70795dc7d52a5fe33f458c1690ff4a4
unrolled_ast: b164f33a2444d2ed798cce895b69dd2bf70795dc7d52a5fe33f458c1690ff4a4
ssa_ast: 823a5fa7568459daddc3a48cc6d93b31e168bd6f854c30cfa511f2d1d53bf7d0
flattened_ast: 11ddc16730c3cff2d340ac5956b7c06f3a10553f548a8b7e561f1e1e6323cf54
- initial_input_ast: ed167b25b652b04fb46a83f3d1f00179d41fd6a099a3b0fd85153a97080d7600
initial_ast: aa84b3125375727027de88b1b826bf1d15d32c7d22a201537fa761c347b1a05c
unrolled_ast: aa84b3125375727027de88b1b826bf1d15d32c7d22a201537fa761c347b1a05c
ssa_ast: 295cc11e6b8c408156c66aab024ba2cff9c087d16a644005674882a2e67ad32c
flattened_ast: add5592c42dd83fa87dd65ba9104780c1167c8d45c835bb3c78024d6767fcfa3

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: b6047e3825e6fe87f55510f8619d842e78d01ae4c9a575653387c74ba2a64947
initial_ast: 88b3b1841e04034444def2cc396a3135180aec9a334c0a2c9a96391df5e160ef
unrolled_ast: 88b3b1841e04034444def2cc396a3135180aec9a334c0a2c9a96391df5e160ef
ssa_ast: 810b4acafbb1f7f1403687533bf067e78ecb176fbb6fac8fcce0f46ca3629658
flattened_ast: ae8a55823da0979c7b870294bfa821ab8c808dde2fb78df654f625e765e8b10b
- initial_input_ast: a754e09f32a2be889b9bebe41a518a9f93c657a46f905e4b4e6dcf5c90913d8f
initial_ast: 24154a2ea0ec4b62fcd3c3e43849d994da755e169ebab087523533dbcdb0e24f
unrolled_ast: 24154a2ea0ec4b62fcd3c3e43849d994da755e169ebab087523533dbcdb0e24f
ssa_ast: fd76b1416cbe2e989c986ebeb6738291896a6845fa46d0edfcb65f4fa0d2fccc
flattened_ast: c3e03eabe375db187d8468df3b3f2eae89425f00e80aa30cec3d3dcad58fd86c

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 7f1729e4c0931b06ecd4e3c7d253eb806dcca0f20343ae891f89fe635798e88c
initial_ast: 26f27443df6965929f39ad85a5672c1397d6c9c95c82b5d88c22a108bf63effb
unrolled_ast: 26f27443df6965929f39ad85a5672c1397d6c9c95c82b5d88c22a108bf63effb
ssa_ast: 5c52540c147eb2b1f247f975b2afc68ede0b9a1a3f11e07cfd60a7b862ff4dec
flattened_ast: 35ea2811ee73cc6aa65306354047f8e27a209f035a55b1982162184031cf0b9d
- initial_input_ast: df25bbae3428eed2d55c6b916b5c3514f169d59bc2a7d2b0cf52a9595edbbf59
initial_ast: 34f4db31adec68c9d44e38d1bb9d2df6b350bb74a15b8a53e6251d488ac79394
unrolled_ast: 34f4db31adec68c9d44e38d1bb9d2df6b350bb74a15b8a53e6251d488ac79394
ssa_ast: dfe3b26c85619a30b4b794b806e0710e49311d0ec03c09a39b66f18d26aa110f
flattened_ast: ae6bb6653c4762863f61064fd971b6286ff3b8fe87d049d432d96e7606fabfcc

View File

@ -3,8 +3,8 @@ namespace: Compile
expectation: Pass
outputs:
- output:
- initial_input_ast: 03478857540e5a7870c2744783a309ae3a250c149c1363795dc9edce7ccaa91f
initial_ast: 3e3019923d84fe4fdd7bfeeaef02429ba104df5c81b3bb64f27865db99b082d0
unrolled_ast: 3e3019923d84fe4fdd7bfeeaef02429ba104df5c81b3bb64f27865db99b082d0
ssa_ast: 9af75bf66fdd96bf87a1916aa6ef674e5225366d858682b2db863f77fc2a6412
flattened_ast: 8d78a326035a4b9323b953e648b8d5c2ec0469449e91809624c7f4ac6cc7795c
- initial_input_ast: 2cbdda4e21986d49f49f2d1519e7b203e33ca13a44ee9b52c56d14bd01640f79
initial_ast: 8329889a15be7f064c202dbdb51969830921427ed3cb4d1509d77934b4b67ece
unrolled_ast: 8329889a15be7f064c202dbdb51969830921427ed3cb4d1509d77934b4b67ece
ssa_ast: e5721dd8044c77290b7667470d14cdc2b8950d56bf137b0ee2d821e6a88f3ebb
flattened_ast: f45f70763e15995aee04ad5720b27cb2d38bd75f4e6256f68e47702e866ede46

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: no input
initial_ast: 3e817de76bc4333b07a68b28ea8843b299cbb3691840d059d3d5880753d6f2cd
unrolled_ast: 3e817de76bc4333b07a68b28ea8843b299cbb3691840d059d3d5880753d6f2cd
ssa_ast: 936997c5060057a22ccc817c6694eef54e1a0741a893b27442bb536b62efa6e3
flattened_ast: 4209279245bed871047b52fb17e8ce00c67bdc77e5099247b86d6c223d8b6489
initial_ast: 55c0758babd4958107c599d73689e795f747206cf3576a4413ebded0203fd21f
unrolled_ast: 55c0758babd4958107c599d73689e795f747206cf3576a4413ebded0203fd21f
ssa_ast: 8af738fc6ed2db4009aacc313d25f898556ddaec98871de928a05c707a047912
flattened_ast: 54096c32c46f9914c9955651048a68d282eafc8f651c827b639168ff4554a3c5

View File

@ -4,7 +4,7 @@ expectation: Pass
outputs:
- output:
- initial_input_ast: no input
initial_ast: 340c2025886ea8d4ced1e8991f363dcf649207bbdb50acde37daf0746fd52212
unrolled_ast: 340c2025886ea8d4ced1e8991f363dcf649207bbdb50acde37daf0746fd52212
ssa_ast: 340c2025886ea8d4ced1e8991f363dcf649207bbdb50acde37daf0746fd52212
flattened_ast: 17b554572787b6a9a61de853491dbfb924306db79af046bd72f534cde13d801e
initial_ast: 2d001657ae4b10bda5d8c54a150f4812d26a367fe7a7ac8e8a10d9ed581e16e8
unrolled_ast: 2d001657ae4b10bda5d8c54a150f4812d26a367fe7a7ac8e8a10d9ed581e16e8
ssa_ast: 2d001657ae4b10bda5d8c54a150f4812d26a367fe7a7ac8e8a10d9ed581e16e8
flattened_ast: 88770675a124f45e654dd1a28d1f70f0fcb95fb717c4dfcbf6e7240f34116c8e

View File

@ -0,0 +1,56 @@
---
namespace: ParseStatement
expectation: Pass
outputs:
- Assert:
variant:
AssertEq:
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":10,\\\"hi\\\":11}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":13,\\\"hi\\\":14}\"}"
span:
lo: 0
hi: 9
- Assert:
variant:
AssertEq:
- Struct:
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":10,\\\"hi\\\":13}\"}"
members:
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":16,\\\"hi\\\":17}\"}"
expression:
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":19,\\\"hi\\\":20}\"}"
span:
lo: 10
hi: 22
- Struct:
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":24,\\\"hi\\\":27}\"}"
members:
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":30,\\\"hi\\\":31}\"}"
expression:
Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":33,\\\"hi\\\":34}\"}"
span:
lo: 24
hi: 36
span:
lo: 0
hi: 9
- Assert:
variant:
AssertNeq:
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":12}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":14,\\\"hi\\\":15}\"}"
span:
lo: 0
hi: 10
- Assert:
variant:
Assert:
Literal:
Boolean:
- false
- span:
lo: 7
hi: 12
span:
lo: 0
hi: 6

View File

@ -2,55 +2,55 @@
namespace: ParseStatement
expectation: Pass
outputs:
- Console:
function:
- Assert:
variant:
AssertEq:
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":18,\\\"hi\\\":19}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":21,\\\"hi\\\":22}\"}"
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":10,\\\"hi\\\":11}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":13,\\\"hi\\\":14}\"}"
span:
lo: 0
hi: 22
- Console:
function:
hi: 9
- Assert:
variant:
AssertEq:
- Struct:
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":18,\\\"hi\\\":21}\"}"
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":10,\\\"hi\\\":13}\"}"
members:
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":24,\\\"hi\\\":25}\"}"
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":16,\\\"hi\\\":17}\"}"
expression:
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":27,\\\"hi\\\":28}\"}"
Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":19,\\\"hi\\\":20}\"}"
span:
lo: 18
hi: 30
lo: 10
hi: 22
- Struct:
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":32,\\\"hi\\\":35}\"}"
name: "{\"name\":\"Foo\",\"span\":\"{\\\"lo\\\":24,\\\"hi\\\":27}\"}"
members:
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":38,\\\"hi\\\":39}\"}"
- identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":30,\\\"hi\\\":31}\"}"
expression:
Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":41,\\\"hi\\\":42}\"}"
Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":33,\\\"hi\\\":34}\"}"
span:
lo: 32
hi: 44
lo: 24
hi: 36
span:
lo: 0
hi: 44
- Console:
function:
hi: 9
- Assert:
variant:
AssertNeq:
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":19,\\\"hi\\\":20}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":22,\\\"hi\\\":23}\"}"
- Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":12}\"}"
- Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":14,\\\"hi\\\":15}\"}"
span:
lo: 0
hi: 23
- Console:
function:
hi: 10
- Assert:
variant:
Assert:
Literal:
Boolean:
- false
- span:
lo: 15
hi: 20
lo: 7
hi: 12
span:
lo: 0
hi: 20
hi: 6

View File

@ -3,11 +3,14 @@ namespace: ParseStatement
expectation: Fail
outputs:
- "Error [EPAR0370020]: Unicode bidi override code point encountered."
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> test:1:9\n |\n 1 | console.log(1);\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:12\n |\n 1 | console.log(1);\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'test'\n --> test:1:9\n |\n 1 | console.test();\n | ^^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:13\n |\n 1 | console.test();\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'error'\n --> test:1:9\n |\n 1 | console.error(\"{}\", x);\n | ^^^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:14\n |\n 1 | console.error(\"{}\", x);\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'error'\n --> test:1:9\n |\n 1 | console.error(\"{}{}\", x, y);\n | ^^^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:14\n |\n 1 | console.error(\"{}{}\", x, y);\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'error'\n --> test:1:9\n |\n 1 | console.error(\"x\");\n | ^^^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:14\n |\n 1 | console.error(\"x\");\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> test:1:9\n |\n 1 | console.log(\"{}\", x);\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:12\n |\n 1 | console.log(\"{}\", x);\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> test:1:9\n |\n 1 | console.log(\"{}{}\", x, y);\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:12\n |\n 1 | console.log(\"{}{}\", x, y);\n | ^"
- "Error [EPAR0370007]: unexpected identifier: expected 'assert', 'assert_eq', 'assert_neq' -- found 'log'\n --> test:1:9\n |\n 1 | console.log(\"x\");\n | ^^^\nError [EPAR0370005]: expected ; -- found '('\n --> test:1:12\n |\n 1 | console.log(\"x\");\n | ^"
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.log(1);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.test();\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.error(\"{}\", x);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.error(\"{}{}\", x, y);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.error(\"x\");\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.assert(true);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.assert_eq(1u32, 2u32);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.assert_neq(true, false);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.log(\"{}\", x);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.log(\"{}{}\", x, y);\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console.log(\"x\");\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."

View File

@ -26,7 +26,7 @@ outputs:
- "Error [EPAR0370009]: unexpected string: expected 'expression', found '>'\n --> test:1:1\n |\n 1 | > x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', found '..'\n --> test:1:1\n |\n 1 | .. x = 10u8;\n | ^^"
- "Error [EPAR0370005]: expected ; -- found 'x'\n --> test:1:4\n |\n 1 | as x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected . -- found 'x'\n --> test:1:9\n |\n 1 | console x = 10u8;\n | ^"
- "Error [EPAR0370032]: `console` statements are not yet supported.\n --> test:1:1\n |\n 1 | console x = 10u8;\n | ^^^^^^^\n |\n = Consider using `assert`, `assert_eq`, or `assert_neq` instead."
- "Error [EPAR0370005]: expected : -- found '='\n --> test:1:7\n |\n 1 | for x = 10u8;\n | ^"
- "Error [EPAR0370005]: expected { -- found '='\n --> test:1:6\n |\n 1 | if x = 10u8;\n | ^"
- "Error [EPAR0370009]: unexpected string: expected 'expression', found 'else'\n --> test:1:1\n |\n 1 | else x = 10u8;\n | ^^^^"

View File

@ -0,0 +1,12 @@
/*
namespace: ParseStatement
expectation: Pass
*/
assert_eq(x, y);
assert_eq(Foo { x: x }, Foo { x: y });
assert_neq(x, y);
assert(false);

View File

@ -1,12 +0,0 @@
/*
namespace: ParseStatement
expectation: Pass
*/
console.assert_eq(x, y);
console.assert_eq(Foo { x: x }, Foo { x: y });
console.assert_neq(x, y);
console.assert(false);

View File

@ -15,6 +15,11 @@ console.error("{}{}", x, y);
console.error("x");
console.assert(true);
console.assert_eq(1u32, 2u32);
console.assert_neq(true, false);
console.log("{}", x);