mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 18:52:58 +03:00
cargo fmt
This commit is contained in:
parent
0a4069fe39
commit
ecc1fff7fd
@ -395,7 +395,6 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn visit_unary(&mut self, input: &'a UnaryExpression, destination: &Self::AdditionalInput) -> Self::Output {
|
fn visit_unary(&mut self, input: &'a UnaryExpression, destination: &Self::AdditionalInput) -> Self::Output {
|
||||||
match input.op {
|
match input.op {
|
||||||
UnaryOperation::Abs => {
|
UnaryOperation::Abs => {
|
||||||
|
@ -18,8 +18,8 @@ use crate::{Declaration, TypeChecker, VariableSymbol};
|
|||||||
use leo_ast::*;
|
use leo_ast::*;
|
||||||
use leo_errors::TypeCheckerError;
|
use leo_errors::TypeCheckerError;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use leo_span::sym;
|
use leo_span::sym;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||||
fn visit_function(&mut self, input: &'a Function) {
|
fn visit_function(&mut self, input: &'a Function) {
|
||||||
@ -54,12 +54,11 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
|||||||
// Check for conflicting circuit member names.
|
// Check for conflicting circuit member names.
|
||||||
let mut used = HashSet::new();
|
let mut used = HashSet::new();
|
||||||
if !input.members.iter().all(|member| used.insert(member.name())) {
|
if !input.members.iter().all(|member| used.insert(member.name())) {
|
||||||
self.handler
|
self.handler.emit_err(if input.is_record {
|
||||||
.emit_err(if input.is_record {
|
TypeCheckerError::duplicate_record_variable(input.name(), input.span()).into()
|
||||||
TypeCheckerError::duplicate_record_variable(input.name(), input.span()).into()
|
} else {
|
||||||
} else {
|
TypeCheckerError::duplicate_circuit_member(input.name(), input.span()).into()
|
||||||
TypeCheckerError::duplicate_circuit_member(input.name(), input.span()).into()
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For records, enforce presence of `owner: Address` and `balance: u64` members.
|
// For records, enforce presence of `owner: Address` and `balance: u64` members.
|
||||||
@ -67,22 +66,16 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
|||||||
let check_has_field = |need, expected_ty: Type| match input
|
let check_has_field = |need, expected_ty: Type| match input
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|CircuitMember::CircuitVariable(v, t) | (v.name == need).then(|| (v, t)))
|
.find_map(|CircuitMember::CircuitVariable(v, t)| (v.name == need).then(|| (v, t)))
|
||||||
{
|
{
|
||||||
Some((_, actual_ty)) if expected_ty.eq_flat(actual_ty) => {} // All good, found + right type!
|
Some((_, actual_ty)) if expected_ty.eq_flat(actual_ty) => {} // All good, found + right type!
|
||||||
Some((field, _)) => {
|
Some((field, _)) => {
|
||||||
self.handler.emit_err(TypeCheckerError::record_var_wrong_type(
|
self.handler
|
||||||
field,
|
.emit_err(TypeCheckerError::record_var_wrong_type(field, expected_ty, input.span()).into());
|
||||||
expected_ty,
|
|
||||||
input.span(),
|
|
||||||
).into());
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.handler.emit_err(TypeCheckerError::required_record_variable(
|
self.handler
|
||||||
need,
|
.emit_err(TypeCheckerError::required_record_variable(need, expected_ty, input.span()).into());
|
||||||
expected_ty,
|
|
||||||
input.span(),
|
|
||||||
).into());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
check_has_field(sym::owner, Type::Address);
|
check_has_field(sym::owner, Type::Address);
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
// Copyright Rust project developers under MIT or APACHE-2.0.
|
// Copyright Rust project developers under MIT or APACHE-2.0.
|
||||||
|
|
||||||
|
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
use core::cell::{Cell, RefCell};
|
use core::cell::{Cell, RefCell};
|
||||||
use core::mem::{self, MaybeUninit};
|
use core::mem::{self, MaybeUninit};
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// 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/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
//! Defines the `Span` type used to track where code comes from.
|
//! Defines the `Span` type used to track where code comes from.
|
||||||
|
|
||||||
use core::ops::{Add, Sub};
|
use core::ops::{Add, Sub};
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// 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/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
use crate::dropless::DroplessArena;
|
use crate::dropless::DroplessArena;
|
||||||
use crate::source_map::SourceMap;
|
use crate::source_map::SourceMap;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user