merge master

This commit is contained in:
gluaxspeed 2021-07-21 12:05:17 -07:00
commit b7a2626bc4
341 changed files with 1269 additions and 6680 deletions

View File

@ -148,24 +148,28 @@ impl<'a> FromAst<'a, leo_ast::ArrayRangeAccessExpression> for ArrayRangeAccessEx
_ => None,
};
let const_right = match right.map(|x| x.const_value()) {
Some(Some(ConstValue::Int(value))) => {
let value = value.to_usize();
if let Some(value) = value {
if value > parent_size {
return Err(AsgConvertError::array_index_out_of_bounds(
value,
&right.unwrap().span().cloned().unwrap_or_default(),
));
Some(Some(ConstValue::Int(inner_value))) => {
let usize_value = inner_value.to_usize();
if let Some(inner_value) = usize_value {
if inner_value > parent_size {
let error_span = if let Some(right) = right {
right.span().cloned().unwrap_or_default()
} else {
value.span.clone()
};
return Err(AsgConvertError::array_index_out_of_bounds(inner_value, &error_span));
} else if let Some(left) = const_left {
if left > value {
return Err(AsgConvertError::array_index_out_of_bounds(
value,
&right.unwrap().span().cloned().unwrap_or_default(),
));
if left > inner_value {
let error_span = if let Some(right) = right {
right.span().cloned().unwrap_or_default()
} else {
value.span.clone()
};
return Err(AsgConvertError::array_index_out_of_bounds(inner_value, &error_span));
}
}
}
value
usize_value
}
None => Some(parent_size),
_ => None,
@ -188,12 +192,14 @@ impl<'a> FromAst<'a, leo_ast::ArrayRangeAccessExpression> for ArrayRangeAccessEx
));
}
}
if let Some(value) = const_left {
if value + expected_len > parent_size {
return Err(AsgConvertError::array_index_out_of_bounds(
value,
&left.unwrap().span().cloned().unwrap_or_default(),
));
if let Some(left_value) = const_left {
if left_value + expected_len > parent_size {
let error_span = if let Some(left) = left {
left.span().cloned().unwrap_or_default()
} else {
value.span.clone()
};
return Err(AsgConvertError::array_index_out_of_bounds(left_value, &error_span));
}
}
length = Some(expected_len);

View File

@ -118,6 +118,11 @@ impl Ast {
let ast: Program = serde_json::from_str(json)?;
Ok(Self { ast })
}
pub fn from_json_file(path: std::path::PathBuf) -> Result<Self, AstError> {
let data = std::fs::read_to_string(path)?;
Self::from_json_string(&data)
}
}
impl AsRef<Program> for Ast {

View File

@ -18,7 +18,7 @@
use crate::{
constraints::{generate_constraints, generate_test_constraints},
errors::CompilerError,
CompilerOptions, GroupType, Output, OutputFile, TheoremOptions, TypeInferencePhase,
AstSnapshotOptions, CompilerOptions, GroupType, Output, OutputFile, TypeInferencePhase,
};
pub use leo_asg::{new_context, AsgContext as Context, AsgContext};
use leo_asg::{Asg, AsgPass, FormattedError, Program as AsgProgram};
@ -62,7 +62,7 @@ pub struct Compiler<'a, F: PrimeField, G: GroupType<F>> {
context: AsgContext<'a>,
asg: Option<AsgProgram<'a>>,
options: CompilerOptions,
proof_options: TheoremOptions,
ast_snapshot_options: AstSnapshotOptions,
_engine: PhantomData<F>,
_group: PhantomData<G>,
}
@ -77,7 +77,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory: PathBuf,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<TheoremOptions>,
ast_snapshot_options: Option<AstSnapshotOptions>,
) -> Self {
Self {
program_name: package_name.clone(),
@ -88,7 +88,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
asg: None,
context,
options: options.unwrap_or_default(),
proof_options: proof_options.unwrap_or_default(),
ast_snapshot_options: ast_snapshot_options.unwrap_or_default(),
_engine: PhantomData,
_group: PhantomData,
}
@ -107,7 +107,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory: PathBuf,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<TheoremOptions>,
ast_snapshot_options: Option<AstSnapshotOptions>,
) -> Result<Self, CompilerError> {
let mut compiler = Self::new(
package_name,
@ -115,7 +115,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory,
context,
options,
proof_options,
ast_snapshot_options,
);
compiler.parse_program()?;
@ -146,7 +146,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
state_path: &Path,
context: AsgContext<'a>,
options: Option<CompilerOptions>,
proof_options: Option<TheoremOptions>,
ast_snapshot_options: Option<AstSnapshotOptions>,
) -> Result<Self, CompilerError> {
let mut compiler = Self::new(
package_name,
@ -154,7 +154,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
output_directory,
context,
options,
proof_options,
ast_snapshot_options,
);
compiler.parse_input(input_string, input_path, state_string, state_path)?;
@ -235,7 +235,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
let mut ast: leo_ast::Ast = parse_ast(self.main_file_path.to_str().unwrap_or_default(), program_string)?;
if self.proof_options.initial {
if self.ast_snapshot_options.initial {
ast.to_json_file(self.output_directory.clone(), "initial_ast.json")?;
}
@ -243,7 +243,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
if self.options.canonicalization_enabled {
ast.canonicalize()?;
if self.proof_options.canonicalized {
if self.ast_snapshot_options.canonicalized {
ast.to_json_file(self.output_directory.clone(), "canonicalization_ast.json")?;
}
}
@ -261,7 +261,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
&mut leo_imports::ImportParser::new(self.main_file_path.clone()),
)?;
if self.proof_options.type_inferenced {
if self.ast_snapshot_options.type_inferenced {
let new_ast = TypeInferencePhase::default()
.phase_ast(&self.program, &asg.clone().into_repr())
.expect("Failed to produce type inference ast.");

View File

@ -65,3 +65,6 @@ pub use phases::*;
pub mod option;
pub use option::*;
#[cfg(test)]
mod test;

View File

@ -38,13 +38,13 @@ impl Default for CompilerOptions {
}
#[derive(Clone)]
pub struct TheoremOptions {
pub struct AstSnapshotOptions {
pub initial: bool,
pub canonicalized: bool,
pub type_inferenced: bool,
}
impl Default for TheoremOptions {
impl Default for AstSnapshotOptions {
fn default() -> Self {
Self {
initial: false,

View File

@ -17,6 +17,7 @@
use std::path::{Path, PathBuf};
use leo_asg::*;
use leo_ast::{Ast, Program};
use leo_synthesizer::{CircuitSynthesizer, SerializedCircuit, SummarizedCircuit};
use leo_test_framework::{
runner::{Namespace, ParseType, Runner},
@ -25,7 +26,9 @@ use leo_test_framework::{
use serde_yaml::Value;
use snarkvm_curves::{bls12_377::Bls12_377, edwards_bls12::Fq};
use leo_compiler::{compiler::Compiler, errors::CompilerError, targets::edwards_bls12::EdwardsGroupType, Output};
use crate::{
compiler::Compiler, errors::CompilerError, targets::edwards_bls12::EdwardsGroupType, AstSnapshotOptions, Output,
};
pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>;
// pub type EdwardsConstrainedValue = ConstrainedValue<'static, Fq, EdwardsGroupType>;
@ -36,15 +39,35 @@ pub(crate) fn make_test_context() -> AsgContext<'static> {
new_context(allocator)
}
fn new_compiler(path: PathBuf) -> EdwardsTestCompiler {
fn new_compiler(path: PathBuf, theorem_options: Option<AstSnapshotOptions>) -> EdwardsTestCompiler {
let program_name = "test".to_string();
let output_dir = PathBuf::from("/output/");
let output_dir = PathBuf::from("/tmp/output/");
std::fs::create_dir_all(output_dir.clone()).unwrap();
EdwardsTestCompiler::new(program_name, path, output_dir, make_test_context(), None, None)
EdwardsTestCompiler::new(
program_name,
path,
output_dir,
make_test_context(),
None,
theorem_options,
)
}
pub(crate) fn parse_program(program_string: &str) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler("compiler-test".into());
fn hash(input: String) -> String {
use sha2::{Digest, Sha256};
let mut hasher = Sha256::new();
hasher.update(input.as_bytes());
let output = hasher.finalize();
hex::encode(&output[..])
}
pub(crate) fn parse_program(
program_string: &str,
theorem_options: Option<AstSnapshotOptions>,
) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler("compiler-test".into(), theorem_options);
compiler.parse_program_from_string(program_string)?;
@ -63,6 +86,9 @@ struct OutputItem {
struct CompileOutput {
pub circuit: SummarizedCircuit,
pub output: Vec<OutputItem>,
pub initial_ast: String,
pub canonicalized_ast: String,
pub type_inferenced_ast: String,
}
impl Namespace for CompileNamespace {
@ -85,24 +111,30 @@ impl Namespace for CompileNamespace {
// })
// .unwrap_or(test.path.clone());
let parsed = parse_program(&test.content).map_err(|x| x.to_string())?;
let parsed = parse_program(
&test.content,
Some(AstSnapshotOptions {
initial: true,
canonicalized: true,
type_inferenced: true,
}),
)
.map_err(|x| x.to_string())?;
// (name, content)
let mut inputs = vec![];
if let Some(input) = test.config.get("inputs") {
if let Value::Sequence(field) = input {
for map in field {
for (name, value) in map.as_mapping().unwrap().iter() {
// Try to parse string from 'inputs' map, else fail
let value = if let serde_yaml::Value::String(value) = value {
value
} else {
return Err("Expected string in 'inputs' map".to_string());
};
if let Some(Value::Sequence(field)) = test.config.get("inputs") {
for map in field {
for (name, value) in map.as_mapping().unwrap().iter() {
// Try to parse string from 'inputs' map, else fail
let value = if let serde_yaml::Value::String(value) = value {
value
} else {
return Err("Expected string in 'inputs' map".to_string());
};
inputs.push((name.as_str().unwrap().to_string(), value.clone()));
}
inputs.push((name.as_str().unwrap().to_string(), value.clone()));
}
}
}
@ -169,15 +201,38 @@ impl Namespace for CompileNamespace {
} else {
last_circuit = Some(circuit);
}
output_items.push(OutputItem {
input_file: input.0,
output,
});
}
let initial_ast: String = hash(
Ast::from_json_file("/tmp/output/initial_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading initial theorem.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let canonicalized_ast: String = hash(
Ast::from_json_file("/tmp/output/canonicalization_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading canonicalized theorem.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let type_inferenced_ast = hash(
Ast::from_json_file("/tmp/output/type_inferenced_ast.json".into())
.unwrap_or_else(|_| Ast::new(Program::new("Error reading type inferenced theorem.".to_string())))
.to_json_string()
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
let final_output = CompileOutput {
circuit: last_circuit.unwrap(),
output: output_items,
initial_ast,
canonicalized_ast,
type_inferenced_ast,
};
Ok(serde_yaml::to_value(&final_output).expect("serialization failed"))
}

View File

@ -1,359 +0,0 @@
{
"name": "",
"expected_input": [],
"imports": [],
"circuits": {},
"global_consts": {},
"functions": {
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}": {
"annotations": [],
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}",
"input": [
{
"Variable": {
"identifier": "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":15,\\\"col_stop\\\":16,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}",
"const_": false,
"mutable": true,
"type_": {
"Array": [
{
"Array": [
"Group",
[
{
"value": "1"
}
]
]
},
[
{
"value": "2"
}
]
]
},
"span": {
"line_start": 1,
"line_stop": 1,
"col_start": 15,
"col_stop": 16,
"path": "",
"content": "function main(a: [group; (2, 1)]) {"
}
}
}
],
"output": {
"Tuple": []
},
"block": {
"statements": [
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let b = [true; (6, 5, 4, 3, 2)];\\\"}\"}",
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 7,
"col_stop": 8,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
],
"type_": null,
"value": {
"ArrayInit": {
"element": {
"ArrayInit": {
"element": {
"ArrayInit": {
"element": {
"ArrayInit": {
"element": {
"ArrayInit": {
"element": {
"Value": {
"Boolean": [
"true",
{
"line_start": 2,
"line_stop": 2,
"col_start": 12,
"col_stop": 16,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
]
}
},
"dimensions": [
{
"value": "2"
}
],
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 11,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
"dimensions": [
{
"value": "3"
}
],
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 11,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
"dimensions": [
{
"value": "4"
}
],
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 11,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
"dimensions": [
{
"value": "5"
}
],
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 11,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
"dimensions": [
{
"value": "6"
}
],
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 11,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 3,
"col_stop": 34,
"path": "",
"content": " let b = [true; (6, 5, 4, 3, 2)];"
}
}
},
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"c\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let c: [u32; (1, 2)] = [0u32; (1, 2)];\\\"}\"}",
"span": {
"line_start": 3,
"line_stop": 3,
"col_start": 7,
"col_stop": 8,
"path": "",
"content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];"
}
}
],
"type_": {
"Array": [
{
"Array": [
{
"IntegerType": "U32"
},
[
{
"value": "2"
}
]
]
},
[
{
"value": "1"
}
]
]
},
"value": {
"ArrayInit": {
"element": {
"ArrayInit": {
"element": {
"Value": {
"Integer": [
"U32",
"0",
{
"line_start": 3,
"line_stop": 3,
"col_start": 27,
"col_stop": 31,
"path": "",
"content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];"
}
]
}
},
"dimensions": [
{
"value": "2"
}
],
"span": {
"line_start": 3,
"line_stop": 3,
"col_start": 26,
"col_stop": 40,
"path": "",
"content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];"
}
}
},
"dimensions": [
{
"value": "1"
}
],
"span": {
"line_start": 3,
"line_stop": 3,
"col_start": 26,
"col_stop": 40,
"path": "",
"content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];"
}
}
},
"span": {
"line_start": 3,
"line_stop": 3,
"col_start": 3,
"col_stop": 40,
"path": "",
"content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];"
}
}
},
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"d\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let d = [0i8; (1)];\\\"}\"}",
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 7,
"col_stop": 8,
"path": "",
"content": " let d = [0i8; (1)];"
}
}
],
"type_": null,
"value": {
"ArrayInit": {
"element": {
"Value": {
"Integer": [
"I8",
"0",
{
"line_start": 4,
"line_stop": 4,
"col_start": 12,
"col_stop": 15,
"path": "",
"content": " let d = [0i8; (1)];"
}
]
}
},
"dimensions": [
{
"value": "1"
}
],
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 11,
"col_stop": 21,
"path": "",
"content": " let d = [0i8; (1)];"
}
}
},
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 3,
"col_stop": 21,
"path": "",
"content": " let d = [0i8; (1)];"
}
}
}
],
"span": {
"line_start": 1,
"line_stop": 7,
"col_start": 35,
"col_stop": 2,
"path": "",
"content": "function main(a: [group; (2, 1)]) {\n...\n}"
}
},
"span": {
"line_start": 1,
"line_stop": 7,
"col_start": 1,
"col_stop": 2,
"path": "",
"content": "function main(a: [group; (2, 1)]) {\n...\n}\n\n\n\n"
}
}
}
}

View File

@ -1,7 +0,0 @@
function main(a: [group; (2, 1)]) {
let b = [true; (6, 5, 4, 3, 2)];
let c: [u32; (1, 2)] = [0u32; (1, 2)];
let d = [0i8; (1)];
// let d = [true; 0];
// let e = [true; (0)];
}

View File

@ -1,3 +0,0 @@
function main() {
let a = [true; (0)];
}

View File

@ -1,438 +0,0 @@
{
"name": "",
"expected_input": [],
"imports": [],
"circuits": {
"{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}": {
"circuit_name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}",
"members": [
{
"CircuitVariable": [
"{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x: u32;\\\"}\"}",
{
"IntegerType": "U32"
}
]
},
{
"CircuitFunction": {
"annotations": [],
"identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" function new() -> Self {\\\"}\"}",
"input": [],
"output": {
"Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}"
},
"block": {
"statements": [
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let new: Self = Self {\\\"}\"}",
"span": {
"line_start": 5,
"line_stop": 5,
"col_start": 9,
"col_stop": 12,
"path": "",
"content": " let new: Self = Self {"
}
}
],
"type_": {
"Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}"
},
"value": {
"CircuitInit": {
"name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}",
"members": [
{
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x: 1u32\\\"}\"}",
"expression": {
"Value": {
"Integer": [
"U32",
"1",
{
"line_start": 6,
"line_stop": 6,
"col_start": 10,
"col_stop": 14,
"path": "",
"content": " x: 1u32"
}
]
}
}
}
],
"span": {
"line_start": 5,
"line_stop": 7,
"col_start": 21,
"col_stop": 6,
"path": "",
"content": " let new: Self = Self {\n...\n };"
}
}
},
"span": {
"line_start": 5,
"line_stop": 7,
"col_start": 5,
"col_stop": 6,
"path": "",
"content": " let new: Self = Self {\n...\n };"
}
}
},
{
"Return": {
"expression": {
"Identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" return new;\\\"}\"}"
},
"span": {
"line_start": 9,
"line_stop": 9,
"col_start": 5,
"col_stop": 15,
"path": "",
"content": " return new;"
}
}
}
],
"span": {
"line_start": 4,
"line_stop": 10,
"col_start": 26,
"col_stop": 4,
"path": "",
"content": " function new() -> Self {\n...\n }"
}
},
"span": {
"line_start": 4,
"line_stop": 10,
"col_start": 3,
"col_stop": 4,
"path": "",
"content": " function new() -> Self {\n...\n }\n\n\n\n"
}
}
},
{
"CircuitFunction": {
"annotations": [],
"identifier": "{\"name\":\"etc\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" function etc() {\\\"}\"}",
"input": [],
"output": {
"Tuple": []
},
"block": {
"statements": [
{
"Assign": {
"operation": "Assign",
"assignee": {
"identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}",
"accesses": [
{
"ArrayIndex": {
"Call": {
"function": {
"CircuitMemberAccess": {
"circuit": {
"CircuitInit": {
"name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}",
"members": [
{
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":14,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}",
"expression": {
"Value": {
"Implicit": [
"0",
{
"line_start": 13,
"line_stop": 13,
"col_start": 17,
"col_stop": 18,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
]
}
}
}
],
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 19,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"name": "{\"name\":\"func\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":20,\\\"col_stop\\\":24,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}",
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 24,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"arguments": [],
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 26,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
}
}
],
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 6,
"col_stop": 27,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
},
"value": {
"Binary": {
"left": {
"ArrayAccess": {
"array": {
"Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":6,\\\"col_stop\\\":7,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}"
},
"index": {
"Call": {
"function": {
"CircuitMemberAccess": {
"circuit": {
"CircuitInit": {
"name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}",
"members": [
{
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":14,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}",
"expression": {
"Value": {
"Implicit": [
"0",
{
"line_start": 13,
"line_stop": 13,
"col_start": 17,
"col_stop": 18,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
]
}
}
}
],
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 19,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"name": "{\"name\":\"func\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":20,\\\"col_stop\\\":24,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[Self {x: 0}.func()] += 2;\\\"}\"}",
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 24,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"arguments": [],
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 8,
"col_stop": 26,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 6,
"col_stop": 32,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"right": {
"Value": {
"Implicit": [
"2",
{
"line_start": 13,
"line_stop": 13,
"col_start": 31,
"col_stop": 32,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
]
}
},
"op": "Add",
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 6,
"col_stop": 32,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
},
"span": {
"line_start": 13,
"line_stop": 13,
"col_start": 6,
"col_stop": 32,
"path": "",
"content": " y[Self {x: 0}.func()] += 2;"
}
}
}
],
"span": {
"line_start": 12,
"line_stop": 14,
"col_start": 18,
"col_stop": 4,
"path": "",
"content": " function etc() {\n...\n }"
}
},
"span": {
"line_start": 12,
"line_stop": 14,
"col_start": 3,
"col_stop": 4,
"path": "",
"content": " function etc() {\n...\n }"
}
}
}
]
}
},
"global_consts": {},
"functions": {
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": {
"annotations": [],
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}",
"input": [],
"output": {
"Tuple": []
},
"block": {
"statements": [
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":7,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}",
"span": {
"line_start": 18,
"line_stop": 18,
"col_start": 7,
"col_stop": 10,
"path": "",
"content": " let foo: Foo = Foo::new();"
}
}
],
"type_": {
"Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}"
},
"value": {
"Call": {
"function": {
"CircuitStaticFunctionAccess": {
"circuit": {
"Identifier": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":18,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}"
},
"name": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":23,\\\"col_stop\\\":26,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}",
"span": {
"line_start": 18,
"line_stop": 18,
"col_start": 18,
"col_stop": 26,
"path": "",
"content": " let foo: Foo = Foo::new();"
}
}
},
"arguments": [],
"span": {
"line_start": 18,
"line_stop": 18,
"col_start": 18,
"col_stop": 28,
"path": "",
"content": " let foo: Foo = Foo::new();"
}
}
},
"span": {
"line_start": 18,
"line_stop": 18,
"col_start": 3,
"col_stop": 28,
"path": "",
"content": " let foo: Foo = Foo::new();"
}
}
}
],
"span": {
"line_start": 17,
"line_stop": 19,
"col_start": 17,
"col_stop": 2,
"path": "",
"content": "function main() {\n...\n}"
}
},
"span": {
"line_start": 17,
"line_stop": 19,
"col_start": 1,
"col_stop": 2,
"path": "",
"content": "function main() {\n...\n}"
}
}
}
}

View File

@ -1,19 +0,0 @@
circuit Foo {
x: u32;
function new() -> Self {
let new: Self = Self {
x: 1u32
};
return new;
}
function etc() {
y[Self {x: 0}.func()] += 2;
}
}
function main() {
let foo: Foo = Foo::new();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
function main () {
let x = [1u32; 5];
x[..2] += 1;
}

View File

@ -1,2 +0,0 @@
[main]
a: [group; (2, 1)] = [1group; (2, 1)];

View File

@ -1,97 +0,0 @@
// Copyright (C) 2019-2021 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::parse_program;
use leo_ast::Ast;
use leo_parser::parser;
pub fn parse_program_ast(file_string: &str) -> Ast {
const TEST_PROGRAM_PATH: &str = "";
let test_program_file_path = std::path::PathBuf::from(TEST_PROGRAM_PATH);
let mut ast = Ast::new(
parser::parse(test_program_file_path.to_str().expect("unwrap fail"), &file_string)
.expect("Failed to parse file."),
);
ast.canonicalize().expect("Failed to canonicalize program.");
ast
}
#[test]
fn test_big_self_in_circuit_replacement() {
// Check program is valid.
let program_string = include_str!("big_self_in_circuit_replacement.leo");
// Check we get expected ast.
let ast = parse_program_ast(program_string);
let expected_json = include_str!("big_self_in_circuit_replacement.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}
#[test]
fn test_big_self_outside_circuit_fail() {
// Check program is invalid.
let program_string = include_str!("big_self_outside_circuit_fail.leo");
let program = parse_program(program_string);
assert!(program.is_err());
}
#[test]
fn test_array_expansion() {
let program_string = include_str!("array_expansion.leo");
let ast = parse_program_ast(program_string);
let expected_json = include_str!("array_expansion.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}
#[test]
fn test_array_size_zero_fail() {
let program_string = include_str!("array_size_zero_fail.leo");
let program = parse_program(program_string);
assert!(program.is_err());
}
#[test]
fn test_compound_assignment() {
let program_string = include_str!("compound_assignment.leo");
let ast = parse_program_ast(program_string);
let expected_json = include_str!("compound_assignment.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}
#[test]
fn test_illegal_array_range_fail() {
// Check program is invalid.
let program_string = include_str!("illegal_array_range_fail.leo");
let program = parse_program(program_string);
assert!(program.is_err());
}
#[test]
fn test_string_transformation() {
let program_string = include_str!("string_transformation.leo");
let ast = parse_program_ast(program_string);
let expected_json = include_str!("string_transformation.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
function main() {
let s = "\u{2764}ello, World!\u{DDDD}";
s[..2] = "he";
let x = false;
x = "test1" == "test2";
let z = [1u8, 2u8, 3u8, 4u8];
z[0.."test" == "test"? 2 : 2] = x[0..2];
}

View File

@ -1 +0,0 @@
[registers]

View File

@ -1,120 +0,0 @@
// Copyright (C) 2019-2021 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/>.
// allow the use of EdwardsTestCompiler::parse_program_from_string for tests
#![allow(deprecated)]
pub mod canonicalization;
pub mod type_inference;
use leo_asg::{new_alloc_context, new_context, AsgContext};
use leo_compiler::{
compiler::Compiler, errors::CompilerError, group::targets::edwards_bls12::EdwardsGroupType, ConstrainedValue,
OutputBytes,
};
use snarkvm_curves::edwards_bls12::Fq;
use snarkvm_r1cs::TestConstraintSystem;
use std::path::PathBuf;
pub const TEST_OUTPUT_DIRECTORY: &str = "/output/";
const EMPTY_FILE: &str = "";
pub type EdwardsTestCompiler = Compiler<'static, Fq, EdwardsGroupType>;
pub type EdwardsConstrainedValue = ConstrainedValue<'static, Fq, EdwardsGroupType>;
//convenience function for tests, leaks memory
pub(crate) fn make_test_context() -> AsgContext<'static> {
let allocator = Box::leak(Box::new(new_alloc_context()));
new_context(allocator)
}
fn new_compiler() -> EdwardsTestCompiler {
let program_name = "test".to_string();
let path = PathBuf::from("/test/src/main.leo");
let output_dir = PathBuf::from(TEST_OUTPUT_DIRECTORY);
EdwardsTestCompiler::new(program_name, path, output_dir, make_test_context(), None, None)
}
pub(crate) fn parse_program(program_string: &str) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler();
compiler.parse_program_from_string(program_string)?;
Ok(compiler)
}
pub fn parse_program_with_input(
program_string: &str,
input_string: &str,
) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler();
let path = PathBuf::new();
compiler.parse_input(input_string, &path, EMPTY_FILE, &path)?;
compiler.parse_program_from_string(program_string)?;
Ok(compiler)
}
pub fn parse_program_with_state(
program_string: &str,
state_string: &str,
) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler();
let path = PathBuf::new();
compiler.parse_input(EMPTY_FILE, &path, state_string, &path)?;
compiler.parse_program_from_string(program_string)?;
Ok(compiler)
}
pub fn parse_program_with_input_and_state(
program_string: &str,
input_string: &str,
state_string: &str,
) -> Result<EdwardsTestCompiler, CompilerError> {
let mut compiler = new_compiler();
let path = PathBuf::new();
compiler.parse_input(input_string, &path, state_string, &path)?;
compiler.parse_program_from_string(&program_string)?;
Ok(compiler)
}
pub(crate) fn get_output(program: EdwardsTestCompiler) -> OutputBytes {
// synthesize the circuit on the test constraint system
let mut cs = TestConstraintSystem::<Fq>::new();
let output = program.compile_constraints(&mut cs).unwrap();
// assert the constraint system is satisfied
assert!(cs.is_satisfied());
output.into()
}
pub(crate) fn assert_satisfied(program: EdwardsTestCompiler) {
let empty_output_bytes = include_bytes!("compiler_output/empty.out");
let res = get_output(program);
// assert that the output is empty
assert_eq!(empty_output_bytes, res.bytes().as_slice());
}

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +0,0 @@
circuit Foo {}
function two() -> u8 {
return 2u8;
}
const ONE = 1u8;
function main() {
const a = 1u8;
const b = 1field;
const c = 1group;
const d = (0, 1)group;
const e = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const f = two();
const g = [0u8; (3, 2)];
const h = [[0u8; 3]; 2];
const i = [1u8, 1u8, 1u8];
const j = true;
const k = (1u8, 1u8);
const l = (1u8, 1u8, true);
const m = Foo {};
const n = 'a';
const o = "Hello, World!";
const p = [...[1u8], ...[2u8]];
const q = [...p, 3u8] == [1u8, 2u8, 3u8];
}

View File

@ -1,243 +0,0 @@
{
"name": "",
"expected_input": [],
"imports": [],
"circuits": {},
"global_consts": {},
"functions": {
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": {
"annotations": [],
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}",
"input": [],
"output": {
"Tuple": []
},
"block": {
"statements": [
{
"Definition": {
"declaration_type": "Let",
"variable_names": [
{
"mutable": true,
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let x = 10u16;\\\"}\"}",
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 9,
"col_stop": 10,
"path": "",
"content": " let x = 10u16;"
}
}
],
"type_": {
"IntegerType": "U16"
},
"value": {
"Value": {
"Integer": [
"U16",
"10",
{
"line_start": 2,
"line_stop": 2,
"col_start": 13,
"col_stop": 18,
"path": "",
"content": " let x = 10u16;"
}
]
}
},
"span": {
"line_start": 2,
"line_stop": 2,
"col_start": 5,
"col_stop": 18,
"path": "",
"content": " let x = 10u16;"
}
}
},
{
"Iteration": {
"variable": "{\"name\":\"i\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" for i in 0..3 {\\\"}\"}",
"start": {
"Value": {
"Integer": [
"U32",
"0",
{
"line_start": 3,
"line_stop": 3,
"col_start": 14,
"col_stop": 15,
"path": "",
"content": " for i in 0..3 {"
}
]
}
},
"stop": {
"Value": {
"Integer": [
"U32",
"3",
{
"line_start": 3,
"line_stop": 3,
"col_start": 17,
"col_stop": 18,
"path": "",
"content": " for i in 0..3 {"
}
]
}
},
"block": {
"statements": [
{
"Assign": {
"operation": "Assign",
"assignee": {
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x -= 1;\\\"}\"}",
"accesses": [],
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 9,
"col_stop": 10,
"path": "",
"content": " x -= 1;"
}
},
"value": {
"Binary": {
"left": {
"Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":9,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x -= 1;\\\"}\"}"
},
"right": {
"Value": {
"Integer": [
"U16",
"1",
{
"line_start": 4,
"line_stop": 4,
"col_start": 14,
"col_stop": 15,
"path": "",
"content": " x -= 1;"
}
]
}
},
"op": "Sub",
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 9,
"col_stop": 15,
"path": "",
"content": " x -= 1;"
}
}
},
"span": {
"line_start": 4,
"line_stop": 4,
"col_start": 9,
"col_stop": 15,
"path": "",
"content": " x -= 1;"
}
}
}
],
"span": {
"line_start": 3,
"line_stop": 5,
"col_start": 19,
"col_stop": 6,
"path": "",
"content": " for i in 0..3 {\n...\n }"
}
},
"span": {
"line_start": 3,
"line_stop": 5,
"col_start": 5,
"col_stop": 6,
"path": "",
"content": " for i in 0..3 {\n...\n }"
}
}
},
{
"Console": {
"function": {
"Assert": {
"Binary": {
"left": {
"Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":20,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(x == 7u16);\\\"}\"}"
},
"right": {
"Value": {
"Integer": [
"U16",
"7",
{
"line_start": 6,
"line_stop": 6,
"col_start": 25,
"col_stop": 29,
"path": "",
"content": " console.assert(x == 7u16);"
}
]
}
},
"op": "Eq",
"span": {
"line_start": 6,
"line_stop": 6,
"col_start": 20,
"col_stop": 29,
"path": "",
"content": " console.assert(x == 7u16);"
}
}
}
},
"span": {
"line_start": 6,
"line_stop": 6,
"col_start": 5,
"col_stop": 29,
"path": "",
"content": " console.assert(x == 7u16);"
}
}
}
],
"span": {
"line_start": 1,
"line_stop": 7,
"col_start": 17,
"col_stop": 2,
"path": "",
"content": "function main() {\n...\n}"
}
},
"span": {
"line_start": 1,
"line_stop": 7,
"col_start": 1,
"col_stop": 2,
"path": "",
"content": "function main() {\n...\n}\n\n\n\n"
}
}
}
}

View File

@ -1,7 +0,0 @@
function main() {
let x = 10u16;
for i in 0..3 {
x -= 1;
}
console.assert(x == 7u16);
}

View File

@ -1,85 +0,0 @@
// Copyright (C) 2019-2021 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::{assert_satisfied, parse_program};
#[allow(unused)]
use leo_asg::{new_context, Asg, AsgContext};
use leo_ast::Ast;
use leo_compiler::TypeInferencePhase;
use leo_imports::ImportParser;
use leo_parser::parser;
thread_local! {
static THREAD_GLOBAL_CONTEXT: AsgContext<'static> = {
let leaked = Box::leak(Box::new(leo_asg::new_alloc_context()));
leo_asg::new_context(leaked)
}
}
pub fn thread_leaked_context() -> AsgContext<'static> {
THREAD_GLOBAL_CONTEXT.with(|f| *f)
}
pub fn parse_program_ast(file_string: &str) -> Ast {
const TEST_PROGRAM_PATH: &str = "";
let test_program_file_path = std::path::PathBuf::from(TEST_PROGRAM_PATH);
let mut ast = Ast::new(
parser::parse(test_program_file_path.to_str().expect("unwrap fail"), &file_string)
.expect("Failed to parse file."),
);
ast.canonicalize().expect("Failed to canonicalize program.");
let program = ast.clone().into_repr();
let asg = Asg::new(thread_leaked_context(), &program, &mut ImportParser::default())
.expect("Failed to create ASG from AST");
let new_ast = TypeInferencePhase::default()
.phase_ast(&program, &asg.into_repr())
.expect("Failed to produce type inference ast.");
new_ast
}
#[test]
fn test_basic() {
// Check program is valid.
let program_string = include_str!("basic.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
// Check we get expected ast.
let ast = parse_program_ast(program_string);
let expected_json = include_str!("basic.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}
#[test]
fn test_for_loop_and_compound() {
// Check program is valid.
let program_string = include_str!("for_loop_and_compound.leo");
let program = parse_program(program_string).unwrap();
assert_satisfied(program);
// Check we get expected ast.
let ast = parse_program_ast(program_string);
let expected_json = include_str!("for_loop_and_compound.json");
let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json.");
assert_eq!(expected_ast, ast);
}

View File

@ -25,9 +25,7 @@ that we suggest few changes to Leo CLI and Manifest:
- allow custom names for imports to manually resolve name conflicts;
- add "curve" and "proving system" sections to the Manifest;
- add "include" and "exclude" parameters for "proving system" and "curve";
Later this solution can be improved by adding a lock-file which would lock
imported packages based on both their contents and version.
- add a lock file which would store imported dependencies and their relations;
# Motivation
@ -109,12 +107,7 @@ To support updated Manifest new command should be added to Leo CLI.
```bash
# pull imports
leo install
```
Alternatively it can be called `pull`.
```
leo pull
leo fetch
```
## Imports Restructurization
@ -155,6 +148,44 @@ first-program => author1-program@0.1.0
second-program => author2-program2@1.0.4
```
## Leo.lock
For imports map to be generated and read by the Leo binary and then by the Leo compiler,
a lock file needs to be created. Lock file should be generated by the `leo fetch` command,
which will pull the dependencies, process their manifests, and put the required information
to the file in the root directory of the program called `Leo.lock`.
Suggested structure of this file is similar to the Cargo.lock file:
```
[[package]]
name = "suit-mk2"
version = "0.2.0"
author = "ironman"
import_name = "suit-mk2"
[package.dependencies]
garbage = "ironman-suit@0.1.0"
[[package]]
name = "suit"
version = "0.1.0"
author = "ironman"
import_name = "garbage"
```
In the example above, you can see that all program dependencies are defined as an
array called `package`. Each of the dependencies contains main information about
it, including the `import_name` field which is the imported package's name in
the Leo program. Also, it stores relationships between these dependencies in the
field `dependencies`.
The format described here allows the Leo binary to form an imports map which can be
passed to the compiler.
It is important to note that Leo.lock file is created only when a package has dependencies.
For programs with no dependencies, a lock file is not required and not created.
## Recursive Dependencies
This improvement introduces recursive dependencies. To solve this case preemptively

View File

@ -94,6 +94,26 @@ for i in 0..5 {}
for i in 0..=5 {}
```
## Step and Direction
We remark that the step of both counting-up and counting-down loops is implicitly 1;
that is, the loop variable is incremented or decremented by 1.
Whether the loop counts up or down is determined by how the starting and ending bounds compare.
Note that the bounds are not necessarily literals;
they may be more complex `const` expressions, and thus in general their values are resolved at code flattening time.
Because of the type restrictions on bounds, their values are always non-negative integers.
If `S` is the integer value of the starting bound and `E` is the integer value of the ending bound,
there are several cases to consider:
1. If `S == E` and the ending bound is exclusive, there is no actual loop; the range is empty.
2. If `S == E` and the ending bound is inclusive, the loop consists of just one iteration; the loop counts neither up nor down.
3. If `S < E` and the ending bound is exclusive, the loop counts up, from `S` to `E-1`.
4. If `S < E` and the ending bound is inclusive, the loop counts up, from `S` to `E`.
5. If `S > E` and the ending bound is exclusive, the loop counts down, from `S` to `E+1`.
6. If `S > E` and the ending bound is inclusive, the loop counts down, from `S` to `E`.
Cases 3 and 5 consist of one or more iterations; cases 4 and 6 consist of two or more iterations.
## Example
The code example demostrated in the Motivation part of this document

View File

@ -18,7 +18,7 @@ use crate::{commands::Command, context::Context};
use leo_compiler::{
compiler::{thread_leaked_context, Compiler},
group::targets::edwards_bls12::EdwardsGroupType,
CompilerOptions, TheoremOptions,
AstSnapshotOptions, CompilerOptions,
};
use leo_package::{
inputs::*,
@ -45,14 +45,14 @@ pub struct BuildOptions {
pub disable_code_elimination: bool,
#[structopt(long, help = "Disable all compiler optimizations")]
pub disable_all_optimizations: bool,
#[structopt(long, help = "Writes all theorem input AST files.")]
pub enable_all_theorems: bool,
#[structopt(long, help = "Writes AST files needed for the initial theorem before any changes.")]
pub enable_initial_theorem: bool,
#[structopt(long, help = "Writes AST files needed for canonicalization theorem.")]
pub enable_canonicalized_theorem: bool,
#[structopt(long, help = "Writes AST files needed for type inference theorem.")]
pub enable_type_inferenced_theorem: bool,
#[structopt(long, help = "Writes all AST snapshots for the different compiler phases.")]
pub enable_all_ast_snapshots: bool,
#[structopt(long, help = "Writes AST snapshot of the initial parse.")]
pub enable_initial_ast_snapshot: bool,
#[structopt(long, help = "Writes AST snapshot after the canonicalization phase.")]
pub enable_canonicalized_ast_snapshot: bool,
#[structopt(long, help = "Writes AST snapshot after the type inference phase.")]
pub enable_type_inferenced_ast_snapshot: bool,
}
impl Default for BuildOptions {
@ -62,10 +62,10 @@ impl Default for BuildOptions {
disable_constant_folding: true,
disable_code_elimination: true,
disable_all_optimizations: true,
enable_all_theorems: false,
enable_initial_theorem: false,
enable_canonicalized_theorem: false,
enable_type_inferenced_theorem: false,
enable_all_ast_snapshots: false,
enable_initial_ast_snapshot: false,
enable_canonicalized_ast_snapshot: false,
enable_type_inferenced_ast_snapshot: false,
}
}
}
@ -88,19 +88,19 @@ impl From<BuildOptions> for CompilerOptions {
}
}
impl From<BuildOptions> for TheoremOptions {
impl From<BuildOptions> for AstSnapshotOptions {
fn from(options: BuildOptions) -> Self {
if options.enable_all_theorems {
TheoremOptions {
if options.enable_all_ast_snapshots {
AstSnapshotOptions {
initial: true,
canonicalized: true,
type_inferenced: true,
}
} else {
TheoremOptions {
initial: options.enable_initial_theorem,
canonicalized: options.enable_canonicalized_theorem,
type_inferenced: options.enable_type_inferenced_theorem,
AstSnapshotOptions {
initial: options.enable_initial_ast_snapshot,
canonicalized: options.enable_canonicalized_ast_snapshot,
type_inferenced: options.enable_type_inferenced_ast_snapshot,
}
}
}
@ -164,7 +164,7 @@ impl Command for Build {
// Log compilation of files to console
tracing::info!("Compiling main program... ({:?})", main_file_path);
if self.compiler_options.disable_canonicalization && self.compiler_options.enable_canonicalized_theorem {
if self.compiler_options.disable_canonicalization && self.compiler_options.enable_canonicalized_ast_snapshot {
tracing::warn!(
"Can not ask for canonicalization theorem without having canonicalization compiler feature enabled."
);

View File

@ -0,0 +1,12 @@
/*
namespace: Compile
expectation: Fail
input_file: input/array_range_access_fail.in
*/
function main (
const x: u32
) {
const y = [1u8; 3];
const z: [u8; 2] = y[..1u32][..x];
}

View File

@ -0,0 +1,9 @@
/*
namespace: Compile
expectation: Fail
input_file: input/dummy.in
*/
function main() {
let a = [true; (0)];
}

View File

@ -0,0 +1,2 @@
[constants]
x: u32 = 1u32;

View File

@ -0,0 +1,27 @@
/*
namespace: Compile
expectation: Pass
input_file: input/dummy.in
*/
circuit Foo {
x: u32;
function new() -> Self {
let new: Self = Self {
x: 1u32
};
return new;
}
function etc() {
let y = [0u32, 1, 2, 3];
y[Self {x: 0}.x] += 2;
}
}
function main(y: bool) -> bool {
let foo: Foo = Foo::new();
return foo.x == 1u32 && y;
}

View File

@ -1,3 +1,9 @@
/*
namespace: Compile
expectation: Fail
input_file: input/dummy.in
*/
circuit Foo {
x: u32;

View File

@ -1,3 +1,9 @@
/*
namespace: Compile
expectation: Pass
input_file: inputs/dummy.in
*/
circuit Foo {
f: u8;
y: (u8, u8);
@ -7,37 +13,33 @@ circuit Foo {
return 1u16;
}
}
function main() {
function main(k: bool) -> bool {
let x = 10u32;
x += 20;
console.assert(x == 30u32);
let w = 3u32;
w += x;
console.assert(w == 33u32);
let y = [1u8, 2u8, 3, 4];
y[0] += 3u8;
y[0..3][1] *= 3;
console.assert(y[0] == 4u8);
console.assert(y[1] == 6u8);
let z = (1u8, 2u8);
z.1 += 3u8;
console.assert(z.1 == 5u8);
let foo = Foo { f: 6u8, y: (1u8, 1u8) };
foo.f += 2u8;
console.assert(foo.f == 8u8);
let complex = 2u8;
complex += 22u8 - 2u8+ 1u8;
console.assert(complex == 23u8);
let a = [[0u8; 1]; 4];
a[2][0] += 1u8;
console.assert(a[2][0] == 1u8);
let b = [0u8; (4, 1)];
b[2][0] += 1u8;
console.assert(a[2][0] == 1u8);
return x == 30u32 && w == 33u32 && y[0] == 4u8 && y[1] == 6u8
&& z.1 == 5u8 && foo.f == 8u8 && a[2][0] == 1u8 && a[2][0] == 1u8
&& k;
}

View File

@ -0,0 +1,5 @@
[main]
k: bool = true;
[registers]
r0: bool = true;

View File

@ -0,0 +1,5 @@
[main]
s2: [char; 2] = "he";
[registers]
out: bool = true;

View File

@ -0,0 +1,14 @@
/*
namespace: Compile
expectation: Pass
input_file: inputs/two.in
*/
function main(s2: [char; 2]) -> bool {
let s = "\u{2764}ello, World!\u{DDDD}";
s[..2] = s2;
let x = "test1";
let z = [1u8, 2u8, 3u8, 4u8];
z[0.."test" == "test" ? 2 : 2] = [10u8, 10];
return z == [10u8, 10, 3, 4] && s == "hello, World!\u{DDDD}";
}

View File

@ -22,3 +22,6 @@ outputs:
a:
type: bool
value: "false"
initial_ast: 1b4069c1fe2f0b258116c5864b19dfb2205e3cd8e13ea79d78fcdb0e9c1a8d50
canonicalized_ast: 1b4069c1fe2f0b258116c5864b19dfb2205e3cd8e13ea79d78fcdb0e9c1a8d50
type_inferenced_ast: d2aefbdd9fd4c931d4ee60f1a435f3da0d827e7425d2fd0a9868de22cc11ed73

View File

@ -22,3 +22,6 @@ outputs:
a:
type: bool
value: "false"
initial_ast: 975c6893ed20b632a3dc9c39f7fe9f381e7dda4b17b6c1f05ff7480e3bf2ee9d
canonicalized_ast: 975c6893ed20b632a3dc9c39f7fe9f381e7dda4b17b6c1f05ff7480e3bf2ee9d
type_inferenced_ast: bbc3818f0267a746d6ab324ef9b9de489ca65cd1624f528dae941841f39517af

View File

@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- " --> compiler-test:7:24\n |\n 7 | const z: [u8; 2] = y[..1u32][..x];\n | ^^^^^^^^^^^^^^\n |\n = array index out of bounds: '0'"

View File

@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- " --> compiler-test:4:13\n |\n 4 | let a = [true; (0)];\n | ^^^^^^^^^^^\n |\n = received dimension size of 0, expected it to be 1 or larger."

View File

@ -16,3 +16,6 @@ outputs:
out:
type: bool
value: "true"
initial_ast: 9808de8c342c41e060d3d3134eb168c8d8cc3ff0641cb8d9779a1746b9fa1687
canonicalized_ast: 1479a9afd623ad11ca137555fd86a3f0a6da39641d5b2da712273242541c246e
type_inferenced_ast: 9bf998e088b9cce0f40a0326fa8e744c88d8168e04c563a2fbd6a57acd23da1f

View File

@ -22,3 +22,6 @@ outputs:
x:
type: bool
value: "false"
initial_ast: 25f4af112eb1512952d78bb7fa1d5287e3ab778255307f69304bbe1756575085
canonicalized_ast: 248b7cc7462c3f035f337c9232a08bb5a911d7f4e153dd804a32bc597adb0210
type_inferenced_ast: ebc3a5632c2d65e51cd9934b1ee4e395867808deeda3ecddfeaebb1b08093ed7

View File

@ -22,3 +22,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: b3bae883863f88babaafa80d4c029974767fba5fea89ac8c2ab10512e61a38ba
canonicalized_ast: 9070de3276acf8d06ac58439247130e444c9b02de25b968ad1fc746650a1896c
type_inferenced_ast: 40a38002031be2cf0141c9ea33562fe69fc3891baeba9c92c487915b97d82507

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: f5e4014d45239734a04d57c7b130fdf9752de245a4341062063aa5e818c5aa05
canonicalized_ast: 8c16a6b011fc067411acaa497386bc5df9b96b91ef739f4992ba416ecf98bafc
type_inferenced_ast: 17d810699ef381a0a9c4efcd2ad6da64b76ce5d629c05db7b2d07d563e077548

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: 25f4af112eb1512952d78bb7fa1d5287e3ab778255307f69304bbe1756575085
canonicalized_ast: 248b7cc7462c3f035f337c9232a08bb5a911d7f4e153dd804a32bc597adb0210
type_inferenced_ast: ebc3a5632c2d65e51cd9934b1ee4e395867808deeda3ecddfeaebb1b08093ed7

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 21f90ee0a01e1238101360b72909766a148155d853fd903a3031d66340915101
canonicalized_ast: cccb2040ce9b654f27e9a8e36976f220545c2888ed2aa9db73843b38407322f2
type_inferenced_ast: 7cee4f94edf86b6c61af5dbb389b8901c57292810abf4cd6b4855dfee40370c7

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 796cfe23085a2fd72700df353d266d3e2f62e893faeba8ed1af5ee5178f8e706
canonicalized_ast: d06970075b65456a138d9286fd3c445c928a55bf9819d98603b494c38563eae1
type_inferenced_ast: 41b1e49c972a34ed3d4629feabe3cb37f2078ba44fd1f3bee0a1888ca86f7ae4

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 3c24983a1b881bd00f5f0fd3a40b471a35f5252798f4ed81784b68693529ad59
canonicalized_ast: 177d06133dcc527a3110335158a888f4a0e5a5e904c2d6df57807563fd0ab386
type_inferenced_ast: 06e32299c26e20b9a25104686911ecd4e94123bd8a90e7890a244b6288678f27

View File

@ -22,3 +22,6 @@ outputs:
r:
type: "[u8; 3]"
value: "\"123\""
initial_ast: 81dd2c459d5a1bff4963fb2cfdc67348183061934025b96739dc05c7b65a2a8b
canonicalized_ast: 81dd2c459d5a1bff4963fb2cfdc67348183061934025b96739dc05c7b65a2a8b
type_inferenced_ast: fcb8de69c92dff4a4adb8a160fc3b78042f394cd0dc627c5bf06820a095d7012

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: ca5fc7bf19d8e6ee1b1421f1a37ea84c42bc89e8ac90711488bc17e996e88a91
canonicalized_ast: ca5fc7bf19d8e6ee1b1421f1a37ea84c42bc89e8ac90711488bc17e996e88a91
type_inferenced_ast: 2823901914ffea0d4cfcf449b9e45b46f67255e0b50f7a946b0552b240bedc0d

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: a588964cfb6989b22b8bf7d6feaf90d09e228d61b09a48fd4e5e4b44473b5bd0
canonicalized_ast: a588964cfb6989b22b8bf7d6feaf90d09e228d61b09a48fd4e5e4b44473b5bd0
type_inferenced_ast: 838744e4d681a06ccb685d0c0de65897234d64f0a49887e896fbda087f3edfd6

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: 2506cc8885eaae80a2ff90d1d231440dcfafd10fd8eb53317112ff2d2240d65e
canonicalized_ast: 2506cc8885eaae80a2ff90d1d231440dcfafd10fd8eb53317112ff2d2240d65e
type_inferenced_ast: bc0e1e40fcb7ac04e1dec943be5b93a1e39d43bee68a26713716765775674577

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: e238db049bc888e9243b421a188edbe5ae160127164b6bb75e54125052455565
canonicalized_ast: e238db049bc888e9243b421a188edbe5ae160127164b6bb75e54125052455565
type_inferenced_ast: e498240b5cb8c4d46a0b1035f208025df8e5feeabf9dddaa859a0a695ae8c5f6

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: d6195e7c9e70c521660ba312c607850110d864a1979004972a0f2908d476efd3
canonicalized_ast: a3483e0912a5d47c95775b1b2d2c62fa5acd5f3c0432757dc261475183156490
type_inferenced_ast: 54b0f61496c50ced01700f61d9c3eac6056d3835f38c2f39fe0c20e45447be63

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: 42d14deb7baaf81b59723a453b1aa09e68bfc8677ce2903596de69ad6b7677ab
canonicalized_ast: 42d14deb7baaf81b59723a453b1aa09e68bfc8677ce2903596de69ad6b7677ab
type_inferenced_ast: 1559a3a4db454285ab969d20276d9112fca0b24f6726f64d4b0371dccde32abf

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: c7cf923f9ca2a963279a8ff7ae9aa0a11eaddc8ba3e107d48f3aef1d1c55a50f
canonicalized_ast: c7cf923f9ca2a963279a8ff7ae9aa0a11eaddc8ba3e107d48f3aef1d1c55a50f
type_inferenced_ast: 58b19d80de0abea85877257b60305e1f7b9d2e67044f60d0159699131d4ba6ec

View File

@ -16,3 +16,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: dbc983cae35c2cd763e9bc4505a2d1e6c063fa62ccdc858a75644175512c1558
canonicalized_ast: dbc983cae35c2cd763e9bc4505a2d1e6c063fa62ccdc858a75644175512c1558
type_inferenced_ast: 42686f9d46c46c829259d4b68643d144d126e61a899e3c413ea09d0ed12d24d1

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 42a9307b4efda61137f9816a43e5c07a9d6b143bd88f609be7e549cb3b21d731
canonicalized_ast: 42a9307b4efda61137f9816a43e5c07a9d6b143bd88f609be7e549cb3b21d731
type_inferenced_ast: 67e643a53bb3efb99367869a1f3a937570f61658b004a4261e87b028f4976fad

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 073b0033613b8c2f8ca027d0486697b5503943dbc65cec9cbbc6b5665e7432e4
canonicalized_ast: 6751d75a95af032784678411bb4e0f59b509ec624daea475cab10b9cf14fe6a0
type_inferenced_ast: 9b9ac4ba4533ecae7ec74da2ab929cfa85be393391887e95ffadf4d1df3004be

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: d04220b24fd2648e859fab4caf69727b5532dbe1ee68db9d569153514e161a85
canonicalized_ast: 36d30f97ff15f08a4a88b384a362168014d56bc90d6a3837fd213b2acfc42357
type_inferenced_ast: 363bdf0ef5cf40b1b63a2cefa3d509ca731809568b7392899cbe73ec13104ecd

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 15fa7dd3949e323b759a7290ff433fb0f6ec83308b1b9b1a6bb129650191bc80
canonicalized_ast: 6a0262a7865ecf453b147449c52f23a1ffb38995c45d0a7c23a78255b9cbbb1b
type_inferenced_ast: 571acef2dd154ad80da051c43f402a9d10593c07b234de69fe9fc19284f09849

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: ec1e31c0b1e2cc2cfa1476b9189d1b3e95e786d5b55e4c350a6888860613f4b2
canonicalized_ast: dacc5bfe970669abcebe9363e0bc84fe7fb8e0c816dda756b00cc38ae993e781
type_inferenced_ast: f8c48aff4a11661fe164e69af32a99a5259f05a10287de26aea2fd323d4744ef

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 37ec6089b9e1af0c552e259848d1ecd8bb361dd8a5c348d6b34f7f5262dc6f40
canonicalized_ast: ad2b199caadb797e02aded3020468c9d7a2b3094652c3b27436b8f98cc71dc05
type_inferenced_ast: cb373502d7141af431342592470482ef936a5fc9e6f4ede8a01e8e98537988de

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: b351c4655069ba4e5ae6759b10109406d64b74c652aab8be3547912df3e10c83
canonicalized_ast: e9e15873ef2727704b7b4f711516e6f8833a177fe4ff9379823dca293ecb8a72
type_inferenced_ast: d040a5aac628379fa32c3e36980f8dac3996a5240bc3482e44c2fdb1d8c3ef60

View File

@ -34,3 +34,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: 457931d2a45a5872b3f523ee9ed3ae922635750e38048927ee39dcd2fdaf338d
canonicalized_ast: 457931d2a45a5872b3f523ee9ed3ae922635750e38048927ee39dcd2fdaf338d
type_inferenced_ast: 5268ad28b10aedcd44c0aafced11ed0351999fceb6a202ed5a1faf833da5c2c4

View File

@ -34,3 +34,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: 57ab6c27f0cc1f947f533b8758a8d7643358eb972fa52d8e97fd12403a3a14e0
canonicalized_ast: 57ab6c27f0cc1f947f533b8758a8d7643358eb972fa52d8e97fd12403a3a14e0
type_inferenced_ast: 55a49f89b8b70b430ca8919b6dbbb3b350a98a8a9e498377d878dd4336a050e6

View File

@ -34,3 +34,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: dcd562246dac98c86986cd3c8519ef6bab0d6ad9eb910ef2b797e25eebf66160
canonicalized_ast: dcd562246dac98c86986cd3c8519ef6bab0d6ad9eb910ef2b797e25eebf66160
type_inferenced_ast: ac5fc2712e702bdd3735bdac2885d028ed66ced47e0f3c310f8c17191a6aa9fe

View File

@ -34,3 +34,6 @@ outputs:
x:
type: bool
value: "false"
initial_ast: aa57c32deb2ca3f69aac1c8d6ab1c9ca787d7539d15dd6ae1d132c4bdf1628f0
canonicalized_ast: aa57c32deb2ca3f69aac1c8d6ab1c9ca787d7539d15dd6ae1d132c4bdf1628f0
type_inferenced_ast: 730367497b7b56381f29321e18eade74d70107a6d8c657b47022215015f53801

View File

@ -34,3 +34,6 @@ outputs:
x:
type: bool
value: "true"
initial_ast: fe77500ebf653bfe8620287f2c9e52f0e985c915a09a285be3b659a308649a65
canonicalized_ast: fe77500ebf653bfe8620287f2c9e52f0e985c915a09a285be3b659a308649a65
type_inferenced_ast: 52112d0a4983f119ba82655780b8aead34d1cced758e5595ce62dbc717f95cae

View File

@ -100,3 +100,6 @@ outputs:
r:
type: char
value: "'\\u{1f62d}'"
initial_ast: 680d480560e2a187669f5bf3c328cee1865021cbe4c19f3350db843d312b6406
canonicalized_ast: 680d480560e2a187669f5bf3c328cee1865021cbe4c19f3350db843d312b6406
type_inferenced_ast: 385365a7d46c458c2d5f94690acc53191bf234bcdb928a9efc454c33ba06718a

View File

@ -100,3 +100,6 @@ outputs:
r:
type: char
value: "'a'"
initial_ast: 66ea1340fc8ae77142ea3d254d8d3350a2775549ea7ba0ab550ec88b5c5721d4
canonicalized_ast: 66ea1340fc8ae77142ea3d254d8d3350a2775549ea7ba0ab550ec88b5c5721d4
type_inferenced_ast: 7b07de0d440a813b674c11dcc71fa4daee8224d5136844d66bc7fafa60f38725

View File

@ -19,3 +19,6 @@ outputs:
r1:
type: bool
value: "true"
initial_ast: 737b6db278359fac5760302a43f0f27b06e38d9dd6affce2b61946545cb475ac
canonicalized_ast: 737b6db278359fac5760302a43f0f27b06e38d9dd6affce2b61946545cb475ac
type_inferenced_ast: 07d7f6418670dca3233f14b5a7dbde73787168b2cb210f6a66860a0d9a0e9ea7

View File

@ -100,3 +100,6 @@ outputs:
r:
type: char
value: "'\\u{1f62d}'"
initial_ast: af450dbf8c804894b41a738de1832af3092cae4d2823b5839da8b7dd6a8679de
canonicalized_ast: af450dbf8c804894b41a738de1832af3092cae4d2823b5839da8b7dd6a8679de
type_inferenced_ast: ec94a20aaab8811399eb3cbd6b30345083f956510e3b5cf6ffb55d3087e83cc8

View File

@ -0,0 +1,21 @@
---
namespace: Compile
expectation: Pass
outputs:
- circuit:
num_public_variables: 0
num_private_variables: 1
num_constraints: 1
at: 042610d0fd1fe6d6ac112138f8755752f44c7d2a00f1b5960574d6da5cda393f
bt: e97756698880ab7555a959a5fb5c6b4e15bd64612aa677adbfe2d0bd91f0a83c
ct: cf1cbb66a638b4860a516671fb74850e6ccf787fe6c4c8d29e9c04efe880bd05
output:
- input_file: input/dummy.in
output:
registers:
r0:
type: bool
value: "true"
initial_ast: aa87a9d1c477e2d5b7ae824fb434188dd6c5c519dd27ebaecd30e44be401ee1b
canonicalized_ast: f188b62839a17478878fe1dfc9863bac20fa1c0c6cf51eae5e13c5f5f79f6c1a
type_inferenced_ast: 9e838aeeebdd2f800c2e7305614f123c27d8390fbadabf1bcb15dae6466669a6

View File

@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- " --> compiler-test:16:3\n |\n 16 | let foo: Self = Foo::new();\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = cannot call keyword `Self` outside of a circuit function"

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: da9350459a9579ec5961fc26b81a67a88060caaaea27448fa02f86271227b213
canonicalized_ast: da9350459a9579ec5961fc26b81a67a88060caaaea27448fa02f86271227b213
type_inferenced_ast: 2dd2c4378253f239047ae310657e24dae70ba7181d1cf08d89007c2f1a37d332

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 583cb3219a67fcbb30d241dec9e2860d99db27b109c8d095c10838ea342efd3c
canonicalized_ast: 583cb3219a67fcbb30d241dec9e2860d99db27b109c8d095c10838ea342efd3c
type_inferenced_ast: bbb33dca916b1310a58492ecd4bc74ed03ef3ab87870391839fc8b627f31e941

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: e96236da6f97f8472930c05f30db95afa0c914060fe3ee908af57dbc1644f6b8
canonicalized_ast: e96236da6f97f8472930c05f30db95afa0c914060fe3ee908af57dbc1644f6b8
type_inferenced_ast: 933e32a944dbeba01b9c1600ccdec94370927087a3a2b5511bdf4767b5fecd7b

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: u32
value: "100"
initial_ast: 7a6b3abb44b3770f98b45c1f961539ae538e1b5fb2b62ae7bffeaf2209739bc3
canonicalized_ast: 7a6b3abb44b3770f98b45c1f961539ae538e1b5fb2b62ae7bffeaf2209739bc3
type_inferenced_ast: 88703ec6b9780a1e7629b14afd0e3da35ff4d68f968db2926242f745d6f61b4d

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 489c3e8ccafc04e118846f4009d93dfbf018902fbdcd1dde6798cc853bcd8903
canonicalized_ast: 4b8614afcbaf258d87202daa83f1340762d9a90f4edd7723b8a83df74acbbeb1
type_inferenced_ast: 3e23d0db328e40ffa2a1ced543295650aa724a8b2dc795bbca54a40ca726b59a

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 8eacc56577069bef188ac3bbabbceaca5fb8955af1e8ea74ef52f01ce7bd4516
canonicalized_ast: 8eacc56577069bef188ac3bbabbceaca5fb8955af1e8ea74ef52f01ce7bd4516
type_inferenced_ast: d5947d1cd599d713fdaafe3cc1084784639c768d5069151dfe7dd0cb02e28ae2

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: f4796f1f9215d0c6d42478aae63b1495dfad36eaaec4a981dddac9def85ffef0
canonicalized_ast: f4796f1f9215d0c6d42478aae63b1495dfad36eaaec4a981dddac9def85ffef0
type_inferenced_ast: f808f56c8af9d6677bf54e7f777b3023f82144462df704dc4f3e39830be4c109

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 75577795f48b9c4f50fed7051e3d76e4b76e3d3b6896ead606d3ebe925e43d2f
canonicalized_ast: 75577795f48b9c4f50fed7051e3d76e4b76e3d3b6896ead606d3ebe925e43d2f
type_inferenced_ast: 60a0557cf60a23b458e3a7ef25299f3fef8cae5c473446b54bb7e98ed91b70f0

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 4c74b65863cddde8ce523495358ab619ec48645dcb8409658a3fb3d7a3821d6d
canonicalized_ast: b5697d5884139da5a68861213ff3c7660f694e682078e1bd350856206e0289b8
type_inferenced_ast: ff4b8f91f014277d6bb2d8d82c31361e5a5c5a46ed87a1e61f0c2e2e8d5fd254

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 701fc149d818f5cfc5c0a2465c46ca76c42d6d558ec0077960a37ae179f401b0
canonicalized_ast: 701fc149d818f5cfc5c0a2465c46ca76c42d6d558ec0077960a37ae179f401b0
type_inferenced_ast: 6a3729bb8e9948a84a0fd5a825510420f57ec7979695dc816795a83258a415e8

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 033ac2bd59dacfd0e1f551feee772337e15a3c9eca8fa64075b1f6c411b2f235
canonicalized_ast: 033ac2bd59dacfd0e1f551feee772337e15a3c9eca8fa64075b1f6c411b2f235
type_inferenced_ast: a90d633d8db0a339186dc314f4de35ed970aec22cfccd423f49824ade7dcf70b

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 35c17de2e9d8a63b29cbeaeeb7eebfa886ff4ae536938e571e953ee206ba8a59
canonicalized_ast: 8f09ad7c9a20220bf8d9fe7e5c84a7c1e99b840fbeb682fb5646df9a05efbd8b
type_inferenced_ast: b1e1e8b1c22a2c98f82d26a1a339952dbe085366b5dc3bb36d71cf4c842739b9

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 5654f2be64d7879bfa2cb49029bd6c3b757c0eb28dd32744de41a28effae5891
canonicalized_ast: 42710d4ec40860cbd1a88da9738960c5a07a6a9937436ec474b3f1bbc805aac4
type_inferenced_ast: d7f138829083963f935922d492a94a693b963d3acee6fadb325be8d99f0e4d19

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 46fccf2a1d04ff7bbfb9a88eeceb6cfd39adcf7ce2e2323d4fb83f4ae3dba273
canonicalized_ast: 222568f9f7b61876690514fdd2dd12419b2e889269a2b7aabd7223d291167da5
type_inferenced_ast: f1a5656978bd48409401788332b1a1d90c969178e65af06b54d5b4445be84375

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 684a9fc0a433525dfbe52d8037588845ad55782b2c1b046bd91049c3b9d9ea4c
canonicalized_ast: 684a9fc0a433525dfbe52d8037588845ad55782b2c1b046bd91049c3b9d9ea4c
type_inferenced_ast: 1fce4132eea4711a6b42fab47478d3608d16df3930554350ed46d865162f7043

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: bd8793749cfd151b89162febc55b6bb6de1be867a0009da6a8470106953db630
canonicalized_ast: 9ecf61f153db9d0912cae6891258e0ebdaecd0da6eef7bbc92c3a6476c7adf6d
type_inferenced_ast: 6908fc70e763ff518a9942a3b930aac64b70075be1b734c2ac93175ca1f16f97

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: e04195ede456babe4121950806163d2cc8c1e4b0180a37969099749ae3dfc3b9
canonicalized_ast: a8673bb8b05eb0289435b8b2335402f022df9ff46db523707cc61eca1b9679ad
type_inferenced_ast: afeabed72941728dc8a8cc0ed27d1e8170f7dd477275be29e794b6c28142f2a7

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: ef90c67bd868ad3d1362b37acad99a97316700c60c9667a4d67b8ad392b2922c
canonicalized_ast: ef90c67bd868ad3d1362b37acad99a97316700c60c9667a4d67b8ad392b2922c
type_inferenced_ast: 636fbf53660cedd9c05b6c361fae19ae5adaae85adc98e888308072ef843f8fa

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 70bf9e6efa84336b4d023dd5484ad15897678c9d4851b5d7cfdb8cb6b79facaa
canonicalized_ast: 70bf9e6efa84336b4d023dd5484ad15897678c9d4851b5d7cfdb8cb6b79facaa
type_inferenced_ast: b410b94ea2070cbfe393229700288a461896a65bb84feed3c0a006aae04566f8

View File

@ -16,3 +16,6 @@ outputs:
- input_file: cond_2.in
output:
registers: {}
initial_ast: d6aad3c859ad1b7f4d3d258c9489cd5a4c26b3a36b10b40dd823c976fb3e1000
canonicalized_ast: 0291e08f42b60c0ef76f666e610bc7ef850f22e3cb849088f516e2feb312cf6e
type_inferenced_ast: f414dd49f054e54d564501fa52bb266dd152d8c32a84dd54b61f782380d02dbe

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 40014c8e30c3aa703f4f0362a16df094a45d5f0df5a94dc26e96d87170784df7
canonicalized_ast: 40014c8e30c3aa703f4f0362a16df094a45d5f0df5a94dc26e96d87170784df7
type_inferenced_ast: fb64ba6e32355ee6df3bd9942ca209f35714ce61511a9b8b867a1587518647a8

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: 2c41e0c55e5a64fd04160a56adf627d90cdbf665ebf1a0fec4a2b9049234652a
canonicalized_ast: 2c41e0c55e5a64fd04160a56adf627d90cdbf665ebf1a0fec4a2b9049234652a
type_inferenced_ast: fa6ccd4112e58ba2e97f3e600dd5d4858c45bb39a858bdd1b1867f494758cbca

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: e239286adc6d00ad3d4328d5911a60d5cf05612610f994faf05208420aa1ca6a
canonicalized_ast: e239286adc6d00ad3d4328d5911a60d5cf05612610f994faf05208420aa1ca6a
type_inferenced_ast: 8d10cefa3e8eb8f7d5668cb153ebc4574ca591905ab22f9ff7c81cb1be0fb110

View File

@ -22,3 +22,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: d81597e32ce19fd62ae7043b42bbd3fd71980c74b913081cb7ed65a249efea67
canonicalized_ast: d81597e32ce19fd62ae7043b42bbd3fd71980c74b913081cb7ed65a249efea67
type_inferenced_ast: 5e163645d00884a3abf845af25115c2479d13517733d42f2a11c092d040d83e8

View File

@ -16,3 +16,6 @@ outputs:
r0:
type: bool
value: "true"
initial_ast: f2a4b944ccecd2be35bab0a4922fb96595b75007db6c35f4be3a1aac08426f9e
canonicalized_ast: f2a4b944ccecd2be35bab0a4922fb96595b75007db6c35f4be3a1aac08426f9e
type_inferenced_ast: bb0b9193a4d3b6d9a91a56820f902c17f0b64705cd6d85cb942479952ec95fab

Some files were not shown because too many files have changed in this diff Show More