mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 02:24:15 +03:00
fix struct field validation. make if conditional parenthesis optional
This commit is contained in:
parent
daf68d7aee
commit
75a47c55dd
@ -360,6 +360,9 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ConstrainedProgram<F, CS> {
|
||||
member.expression,
|
||||
)?;
|
||||
|
||||
// Check member types
|
||||
member_value.expect_type(&field._type)?;
|
||||
|
||||
resolved_members.push(ConstrainedStructMember(member.variable, member_value))
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::errors::{BooleanError, FieldElementError, FunctionError, IntegerError};
|
||||
use crate::errors::{BooleanError, FieldElementError, FunctionError, IntegerError, ValueError};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ExpressionError {
|
||||
@ -13,6 +13,9 @@ pub enum ExpressionError {
|
||||
#[error("{}", _0)]
|
||||
IncompatibleTypes(String),
|
||||
|
||||
#[error("{}", _0)]
|
||||
ValueError(ValueError),
|
||||
|
||||
#[error("{}", _0)]
|
||||
IntegerError(IntegerError),
|
||||
|
||||
@ -81,6 +84,12 @@ impl From<std::io::Error> for ExpressionError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ValueError> for ExpressionError {
|
||||
fn from(error: ValueError) -> Self {
|
||||
ExpressionError::ValueError(error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IntegerError> for ExpressionError {
|
||||
fn from(error: IntegerError) -> Self {
|
||||
ExpressionError::IntegerError(error)
|
||||
|
@ -174,7 +174,7 @@ statement_return = { "return" ~ expression_tuple }
|
||||
statement_definition = { "let" ~ variable ~ (":" ~ _type)? ~ "=" ~ expression }
|
||||
statement_assign = { assignee ~ operation_assign ~ expression }
|
||||
statement_multiple_assignment = { "let" ~ "(" ~ optionally_typed_variable_tuple ~ ")" ~ "=" ~ variable ~ "(" ~ expression_tuple ~ ")" }
|
||||
statement_conditional = {"if" ~ "(" ~ expression ~ ")" ~ "{" ~ NEWLINE* ~ statement+ ~ "}" ~ ("else" ~ conditional_nested_or_end)?}
|
||||
statement_conditional = {"if" ~ (expression | "(" ~ expression ~ ")") ~ "{" ~ NEWLINE* ~ statement+ ~ "}" ~ ("else" ~ conditional_nested_or_end)?}
|
||||
statement_for = { "for" ~ variable ~ "in" ~ expression ~ ".." ~ expression ~ "{" ~ NEWLINE* ~ statement+ ~ "}"}
|
||||
statement_assert = {
|
||||
assert_eq
|
||||
|
0
stdlib/crh/pedersen.leo
Normal file
0
stdlib/crh/pedersen.leo
Normal file
Loading…
Reference in New Issue
Block a user