Skip to content

Commit

Permalink
fix error spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
collinc97 committed Apr 15, 2021
2 parents 1fee0d3 + efa3f78 commit c728fb4
Show file tree
Hide file tree
Showing 238 changed files with 1,071 additions and 1,244 deletions.
30 changes: 15 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ jobs:
export LEO=/home/circleci/project/project/bin/leo
./project/.circleci/leo-login-logout.sh
leo-clone:
docker:
- image: cimg/rust:1.51.0
resource_class: xlarge
steps:
- attach_workspace:
at: /home/circleci/project/
- run:
name: leo clone
command: |
export LEO=/home/circleci/project/project/bin/leo
./project/.circleci/leo-clone.sh
# leo-clone:
# docker:
# - image: cimg/rust:1.51.0
# resource_class: xlarge
# steps:
# - attach_workspace:
# at: /home/circleci/project/
# - run:
# name: leo clone
# command: |
# export LEO=/home/circleci/project/project/bin/leo
# ./project/.circleci/leo-clone.sh

leo-publish:
docker:
Expand Down Expand Up @@ -222,9 +222,9 @@ workflows:
- leo-login-logout:
requires:
- leo-executable
- leo-clone:
requires:
- leo-executable
# - leo-clone:
# requires:
# - leo-executable
- leo-publish:
requires:
- leo-executable
10 changes: 9 additions & 1 deletion .circleci/leo-login-logout.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# leo login & logout

$LEO new my-app && cd my-app || exit 1
$LEO login -u "$ALEO_PM_USERNAME" -p "$ALEO_PM_PASSWORD"
$LEO new my-app && cd my-app || exit 1

cat Leo.toml

# verify that in Leo.toml there's no line with [AUTHOR];
# since CI does not allow showing credentials, we won't see it in the file;
# so the only way to test is to make sure that there's just no [AUTHOR] there
[[ $(cat Leo.toml | grep "\[AUTHOR\]" | wc -l) -eq 0 ]] || exit 1

$LEO add howard/silly-sudoku
$LEO remove silly-sudoku
$LEO logout
5 changes: 5 additions & 0 deletions .circleci/leo-new.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
$LEO new hello-world
ls -la
cd hello-world && ls -la

# verify that in Leo.toml there's a placeholder for author
# because at the time of calling `leo new` user is not logged in
[[ $(cat Leo.toml | grep "\[AUTHOR\]" | wc -l) -eq 1 ]] || exit 1

$LEO run
Empty file added .circleci/r
Empty file.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ version = "0.3.1"
version = "1.4.0"

[dependencies.notify]
version = "4.0.15"
version = "4.0.16"

[dependencies.rand]
version = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion asg/src/checks/return_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a> MonoidalReducerStatement<'a, BoolAnd> for ReturnPathReducer {
if_true.append(if_false.unwrap_or(BoolAnd(false)))
}

fn reduce_formatted_string(&mut self, input: &FormattedString, parameters: Vec<BoolAnd>) -> BoolAnd {
fn reduce_formatted_string(&mut self, input: &FormatString, parameters: Vec<BoolAnd>) -> BoolAnd {
BoolAnd(false)
}

Expand Down
2 changes: 1 addition & 1 deletion asg/src/expression/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> ExpressionNode<'a> for CallExpression<'a> {
}

fn is_mut_ref(&self) -> bool {
false
true
}

fn const_value(&self) -> Option<ConstValue> {
Expand Down
7 changes: 0 additions & 7 deletions asg/src/expression/variable_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ impl<'a> FromAst<'a, leo_ast::Identifier> for &'a Expression<'a> {
expected_type: Option<PartialType<'a>>,
) -> Result<&'a Expression<'a>, AsgConvertError> {
let variable = if value.name.as_ref() == "input" {
if let Some(function) = scope.resolve_current_function() {
if !function.has_input {
return Err(AsgConvertError::unresolved_reference(&value.name, &value.span));
}
} else {
return Err(AsgConvertError::unresolved_reference(&value.name, &value.span));
}
if let Some(input) = scope.resolve_input() {
input.container
} else {
Expand Down
2 changes: 1 addition & 1 deletion asg/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn resolve_core_module<'a>(context: AsgContext<'a>, module: &str) -> Result<
r#"
circuit Blake2s {
function hash(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] {
return [0; 32]
return [0; 32];
}
}
"#,
Expand Down
6 changes: 0 additions & 6 deletions asg/src/program/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub struct Function<'a> {
pub id: u32,
pub name: RefCell<Identifier>,
pub output: Type<'a>,
pub has_input: bool,
pub arguments: IndexMap<String, Cell<&'a Variable<'a>>>,
pub circuit: Cell<Option<&'a Circuit<'a>>>,
pub span: Option<Span>,
Expand Down Expand Up @@ -77,16 +76,12 @@ impl<'a> Function<'a> {
.transpose()?
.unwrap_or_else(|| Type::Tuple(vec![]));
let mut qualifier = FunctionQualifier::Static;
let mut has_input = false;
let new_scope = scope.make_subscope();

let mut arguments = IndexMap::new();
{
for input in value.input.iter() {
match input {
FunctionInput::InputKeyword(_) => {
has_input = true;
}
FunctionInput::SelfKeyword(_) => {
qualifier = FunctionQualifier::SelfRef;
}
Expand Down Expand Up @@ -125,7 +120,6 @@ impl<'a> Function<'a> {
id: scope.context.get_id(),
name: RefCell::new(value.identifier.clone()),
output,
has_input,
arguments,
circuit: Cell::new(None),
body: Cell::new(None),
Expand Down
2 changes: 1 addition & 1 deletion asg/src/reducer/monoidal_director.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl<'a, T: Monoid, R: MonoidalReducerStatement<'a, T>> MonoidalDirector<'a, T,
.reduce_conditional_statement(input, condition, if_true, if_false)
}

pub fn reduce_formatted_string(&mut self, input: &FormattedString<'a>) -> T {
pub fn reduce_formatted_string(&mut self, input: &FormatString<'a>) -> T {
let parameters = input
.parameters
.iter()
Expand Down
2 changes: 1 addition & 1 deletion asg/src/reducer/monoidal_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub trait MonoidalReducerStatement<'a, T: Monoid>: MonoidalReducerExpression<'a,
condition.append(if_true).append_option(if_false)
}

fn reduce_formatted_string(&mut self, input: &FormattedString<'a>, parameters: Vec<T>) -> T {
fn reduce_formatted_string(&mut self, input: &FormatString<'a>, parameters: Vec<T>) -> T {
T::default().append_all(parameters.into_iter())
}

Expand Down
2 changes: 1 addition & 1 deletion asg/src/reducer/reconstructing_director.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'a, R: ReconstructingReducerStatement<'a>> ReconstructingDirector<'a, R> {
.reduce_conditional_statement(input, condition, if_true, if_false)
}

pub fn reduce_formatted_string(&mut self, input: FormattedString<'a>) -> FormattedString<'a> {
pub fn reduce_formatted_string(&mut self, input: FormatString<'a>) -> FormatString<'a> {
let parameters = input
.parameters
.iter()
Expand Down
8 changes: 4 additions & 4 deletions asg/src/reducer/reconstructing_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ pub trait ReconstructingReducerStatement<'a>: ReconstructingReducerExpression<'a

fn reduce_formatted_string(
&mut self,
input: FormattedString<'a>,
input: FormatString<'a>,
parameters: Vec<&'a Expression<'a>>,
) -> FormattedString<'a> {
FormattedString {
) -> FormatString<'a> {
FormatString {
span: input.span,
parts: input.parts,
parameters: parameters.into_iter().map(Cell::new).collect(),
Expand All @@ -293,7 +293,7 @@ pub trait ReconstructingReducerStatement<'a>: ReconstructingReducerExpression<'a
})
}

fn reduce_console_log(&mut self, input: ConsoleStatement<'a>, argument: FormattedString<'a>) -> Statement<'a> {
fn reduce_console_log(&mut self, input: ConsoleStatement<'a>, argument: FormatString<'a>) -> Statement<'a> {
assert!(!matches!(input.function, ConsoleFunction::Assert(_)));
Statement::Console(ConsoleStatement {
parent: input.parent,
Expand Down
2 changes: 1 addition & 1 deletion asg/src/reducer/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub trait StatementVisitor<'a>: ExpressionVisitor<'a> {
Default::default()
}

fn visit_formatted_string(&mut self, input: &FormattedString<'a>) -> VisitResult {
fn visit_formatted_string(&mut self, input: &FormatString<'a>) -> VisitResult {
Default::default()
}

Expand Down
2 changes: 1 addition & 1 deletion asg/src/reducer/visitor_director.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl<'a, R: StatementVisitor<'a>> VisitorDirector<'a, R> {
}
}

pub fn visit_formatted_string(&mut self, input: &FormattedString<'a>) -> ConcreteVisitResult {
pub fn visit_formatted_string(&mut self, input: &FormatString<'a>) -> ConcreteVisitResult {
match self.visitor.visit_formatted_string(input) {
VisitResult::VisitChildren => {
for parameter in input.parameters.iter() {
Expand Down
7 changes: 0 additions & 7 deletions asg/src/statement/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> {
let (name, span) = (&statement.assignee.identifier.name, &statement.assignee.identifier.span);

let variable = if name.as_ref() == "input" {
if let Some(function) = scope.resolve_current_function() {
if !function.has_input {
return Err(AsgConvertError::unresolved_reference(name, &span));
}
} else {
return Err(AsgConvertError::unresolved_reference(name, &span));
}
if let Some(input) = scope.resolve_input() {
input.container
} else {
Expand Down
32 changes: 16 additions & 16 deletions asg/src/statement/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.

use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span, Statement, Type};
use leo_ast::{ConsoleFunction as AstConsoleFunction, FormattedStringPart};
use leo_ast::{ConsoleFunction as AstConsoleFunction, FormatStringPart};

use std::cell::Cell;

// TODO (protryon): Refactor to not require/depend on span
#[derive(Clone)]
pub struct FormattedString<'a> {
pub parts: Vec<FormattedStringPart>,
pub struct FormatString<'a> {
pub parts: Vec<FormatStringPart>,
pub parameters: Vec<Cell<&'a Expression<'a>>>,
pub span: Span,
}

#[derive(Clone)]
pub enum ConsoleFunction<'a> {
Assert(Cell<&'a Expression<'a>>),
Debug(FormattedString<'a>),
Error(FormattedString<'a>),
Log(FormattedString<'a>),
Debug(FormatString<'a>),
Error(FormatString<'a>),
Log(FormatString<'a>),
}

#[derive(Clone)]
Expand All @@ -48,16 +48,16 @@ impl<'a> Node for ConsoleStatement<'a> {
}
}

impl<'a> FromAst<'a, leo_ast::FormattedString> for FormattedString<'a> {
impl<'a> FromAst<'a, leo_ast::FormatString> for FormatString<'a> {
fn from_ast(
scope: &'a Scope<'a>,
value: &leo_ast::FormattedString,
value: &leo_ast::FormatString,
_expected_type: Option<PartialType<'a>>,
) -> Result<Self, AsgConvertError> {
let expected_param_len = value
.parts
.iter()
.filter(|x| matches!(x, FormattedStringPart::Container))
.filter(|x| matches!(x, FormatStringPart::Container))
.count();
if value.parameters.len() != expected_param_len {
// + 1 for formatting string as to not confuse user
Expand All @@ -71,17 +71,17 @@ impl<'a> FromAst<'a, leo_ast::FormattedString> for FormattedString<'a> {
for parameter in value.parameters.iter() {
parameters.push(Cell::new(<&Expression<'a>>::from_ast(scope, parameter, None)?));
}
Ok(FormattedString {
Ok(FormatString {
parts: value.parts.clone(),
parameters,
span: value.span.clone(),
})
}
}

impl<'a> Into<leo_ast::FormattedString> for &FormattedString<'a> {
fn into(self) -> leo_ast::FormattedString {
leo_ast::FormattedString {
impl<'a> Into<leo_ast::FormatString> for &FormatString<'a> {
fn into(self) -> leo_ast::FormatString {
leo_ast::FormatString {
parts: self.parts.clone(),
parameters: self.parameters.iter().map(|e| e.get().into()).collect(),
span: self.span.clone(),
Expand All @@ -103,13 +103,13 @@ impl<'a> FromAst<'a, leo_ast::ConsoleStatement> for ConsoleStatement<'a> {
<&Expression<'a>>::from_ast(scope, expression, Some(Type::Boolean.into()))?,
)),
AstConsoleFunction::Debug(formatted_string) => {
ConsoleFunction::Debug(FormattedString::from_ast(scope, formatted_string, None)?)
ConsoleFunction::Debug(FormatString::from_ast(scope, formatted_string, None)?)
}
AstConsoleFunction::Error(formatted_string) => {
ConsoleFunction::Error(FormattedString::from_ast(scope, formatted_string, None)?)
ConsoleFunction::Error(FormatString::from_ast(scope, formatted_string, None)?)
}
AstConsoleFunction::Log(formatted_string) => {
ConsoleFunction::Log(FormattedString::from_ast(scope, formatted_string, None)?)
ConsoleFunction::Log(FormatString::from_ast(scope, formatted_string, None)?)
}
},
})
Expand Down
2 changes: 1 addition & 1 deletion asg/src/statement/iteration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> {
statement: &leo_ast::IterationStatement,
_expected_type: Option<PartialType<'a>>,
) -> Result<Self, AsgConvertError> {
let expected_index_type = Some(PartialType::Integer(None, Some(IntegerType::U32)));
let expected_index_type = Some(PartialType::Integer(Some(IntegerType::U32), None));
let start = <&Expression<'a>>::from_ast(scope, &statement.start, expected_index_type.clone())?;
let stop = <&Expression<'a>>::from_ast(scope, &statement.stop, expected_index_type)?;

Expand Down
2 changes: 1 addition & 1 deletion asg/tests/fail/circuits/member_function_fail.leo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
circuit Foo {
function echo(x: u32) -> u32 {
return x
return x;
}
}

Expand Down
2 changes: 1 addition & 1 deletion asg/tests/fail/circuits/member_function_invalid.leo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
circuit Foo {
function echo(x: u32) -> u32 {
return x
return x;
}
}

Expand Down
2 changes: 1 addition & 1 deletion asg/tests/fail/circuits/member_static_function_invalid.leo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
circuit Foo {
function echo(x: u32) -> u32 {
return x
return x;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
circuit Foo {
function echo(x: u32) -> u32 {
return x
return x;
}
}

Expand Down
2 changes: 1 addition & 1 deletion asg/tests/fail/circuits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn test_mut_member_function_fail() {
let program_string = r#"
circuit Foo {
function echo(mut self, x: u32) -> u32 {
return x
return x;
}
}
Expand Down
Loading

0 comments on commit c728fb4

Please sign in to comment.