Skip to content

Commit

Permalink
update parser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Jan 23, 2024
1 parent c0355e4 commit f2fca62
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Circuit {
// c++ code at the moment when it is, due to OpcodeLocation needing a comparison
// implementation which is never generated.
//
// TODO: These are only used for constrains that are generating during compilation.
// TODO: These are only used for constrain statements that are generated during codegen.
// TODO: We should move towards having all the checks being evaluated in the same manner
// TODO: as runtime assert messages specified by the user.
pub assert_messages: Vec<(OpcodeLocation, String)>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn create_apply_functions(
"ICE: at least one variant should exist for a dynamic call {signature:?}"
);
let dispatches_to_multiple_functions = variants.len() > 1;
dbg!(variants.clone());

let id = if dispatches_to_multiple_functions {
create_apply_function(ssa, signature.clone(), variants)
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl<'f> Context<'f> {
Instruction::binary(BinaryOp::Mul, rhs, casted_condition),
call_stack,
);
dbg!(message.clone());

Instruction::Constrain(lhs, rhs, message)
}
Instruction::Store { address, value } => {
Expand Down
21 changes: 1 addition & 20 deletions compiler/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,10 +1116,7 @@ impl<'a> Resolver<'a> {
Expression::call(
Expression {
kind: ExpressionKind::Variable(Path {
segments: vec![
// Ident::from("crate"),
Ident::from("resolve_assert_message"),
],
segments: vec![Ident::from("resolve_assert_message")],
kind: PathKind::Crate,
span,
}),
Expand All @@ -1145,22 +1142,6 @@ impl<'a> Resolver<'a> {
Span::default(),
)
};
// dbg!(call_expr.clone());
// let call_expr = Expression::call(
// Expression {
// kind: ExpressionKind::Variable(Path {
// segments: vec![
// Ident::from("std"),
// Ident::from("resolve_assert_message"),
// ],
// kind: PathKind::Dep,
// span: Span::default(),
// }),
// span: Span::default(),
// },
// vec![assert_msg_expr.clone()],
// Span::default(),
// );
self.resolve_expression(call_expr)
});
HirStatement::Constrain(HirConstrainStatement(
Expand Down
26 changes: 18 additions & 8 deletions compiler/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2081,10 +2081,15 @@ mod test {

match parse_with(assertion(expression()), "assert(x == y, \"assertion message\")").unwrap()
{
StatementKind::Constrain(ConstrainStatement(_, message, _)) => {
// TODO: update this test
// assert_eq!(message, Some("assertion message".to_owned()));
}
StatementKind::Constrain(ConstrainStatement(_, message, _)) => match message {
Some(message) => match message.kind {
ExpressionKind::Literal(Literal::Str(message_string)) => {
assert_eq!(message_string, "assertion message".to_owned());
}
_ => unreachable!(),
},
_ => unreachable!(),
},
_ => unreachable!(),
}
}
Expand All @@ -2106,10 +2111,15 @@ mod test {
match parse_with(assertion_eq(expression()), "assert_eq(x, y, \"assertion message\")")
.unwrap()
{
StatementKind::Constrain(ConstrainStatement(_, message, _)) => {
// TODO: update this test
// assert_eq!(message, Some("assertion message".to_owned()));
}
StatementKind::Constrain(ConstrainStatement(_, message, _)) => match message {
Some(message) => match message.kind {
ExpressionKind::Literal(Literal::Str(message_string)) => {
assert_eq!(message_string, "assertion message".to_owned());
}
_ => unreachable!(),
},
_ => unreachable!(),
},
_ => unreachable!(),
}
}
Expand Down

0 comments on commit f2fca62

Please sign in to comment.