merge master

This commit is contained in:
gluax 2021-03-26 11:33:47 -04:00
commit e4d135d2a8
752 changed files with 4255 additions and 1470 deletions

72
Cargo.lock generated
View File

@ -13,9 +13,9 @@ dependencies = [
[[package]]
name = "adler"
version = "1.0.2"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
checksum = "bedc89c5c7b5550ffb9372eb5c5ffc7f9f705cc3f4a128bd4669b9745f555093"
[[package]]
name = "adler32"
@ -188,7 +188,7 @@ dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.12.4",
"generic-array 0.12.3",
]
[[package]]
@ -577,7 +577,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array 0.12.4",
"generic-array 0.12.3",
]
[[package]]
@ -846,9 +846,9 @@ dependencies = [
[[package]]
name = "generic-array"
version = "0.12.4"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
dependencies = [
"typenum",
]
@ -908,9 +908,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "h2"
version = "0.3.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d832b01df74254fe364568d6ddc294443f61cbec82816b60904303af87efae78"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
"bytes",
"fnv",
@ -923,6 +923,7 @@ dependencies = [
"tokio",
"tokio-util",
"tracing",
"tracing-futures",
]
[[package]]
@ -1162,9 +1163,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.48"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc9f84f9b115ce7843d60706df1422a916680bfdfcbdb0447c5614ff9d7e4d78"
checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65"
dependencies = [
"wasm-bindgen",
]
@ -1217,6 +1218,7 @@ dependencies = [
name = "leo-ast"
version = "1.2.3"
dependencies = [
"anyhow",
"criterion",
"indexmap",
"leo-input",
@ -1875,9 +1877,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
version = "0.2.6"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827"
[[package]]
name = "pin-utils"
@ -2382,9 +2384,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.64"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6"
dependencies = [
"itoa",
"ryu",
@ -2935,6 +2937,16 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]]
name = "tracing-log"
version = "0.1.2"
@ -3124,9 +3136,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.71"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7"
checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be"
dependencies = [
"cfg-if 1.0.0",
"serde",
@ -3136,9 +3148,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.71"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8"
checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7"
dependencies = [
"bumpalo",
"lazy_static",
@ -3151,9 +3163,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.21"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e67a5806118af01f0d9045915676b22aaebecf4178ae7021bc171dab0b897ab"
checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@ -3163,9 +3175,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.71"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ac38da8ef716661f0f36c0d8320b89028efe10c7c0afde65baffb496ce0d3b"
checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c"
dependencies = [
"quote 1.0.9",
"wasm-bindgen-macro-support",
@ -3173,9 +3185,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.71"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e"
checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385"
dependencies = [
"proc-macro2 1.0.24",
"quote 1.0.9",
@ -3186,15 +3198,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.71"
version = "0.2.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d6f8ec44822dd71f5f221a5847fb34acd9060535c1211b70a05844c0f6383b1"
checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64"
[[package]]
name = "web-sys"
version = "0.3.48"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec600b26223b2948cedfde2a0aa6756dcf1fef616f43d7b3097aaf53a6c4d92b"
checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -3273,9 +3285,9 @@ dependencies = [
[[package]]
name = "zip"
version = "0.5.11"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8264fcea9b7a036a4a5103d7153e988dbc2ebbafb34f68a3c2d404b6b82d74b6"
checksum = "5a8977234acab718eb2820494b2f96cbb16004c19dddf88b7445b27381450997"
dependencies = [
"byteorder",
"bzip2",

View File

@ -22,6 +22,9 @@
//! A new [`Asg`] type can be created from an [`Ast`].
//! Converting to an [`Asg`] provides greater type safety by canonicalizing and checking program types.
#![allow(clippy::from_over_into)]
#![allow(clippy::result_unit_err)]
#[macro_use]
extern crate thiserror;

View File

@ -68,35 +68,50 @@ impl<'a> Circuit<'a> {
let mut members = circuit.members.borrow_mut();
for member in value.members.iter() {
match member {
leo_ast::CircuitMember::CircuitVariable(name, type_) => {
if members.contains_key(&name.name) {
return Err(AsgConvertError::redefined_circuit_member(
&value.circuit_name.name,
&name.name,
&name.span,
));
}
members.insert(
name.name.clone(),
CircuitMember::Variable(new_scope.resolve_ast_type(type_)?),
);
if let leo_ast::CircuitMember::CircuitVariable(name, type_) = member {
if members.contains_key(&name.name) {
return Err(AsgConvertError::redefined_circuit_member(
&value.circuit_name.name,
&name.name,
&name.span,
));
}
leo_ast::CircuitMember::CircuitFunction(function) => {
if members.contains_key(&function.identifier.name) {
return Err(AsgConvertError::redefined_circuit_member(
&value.circuit_name.name,
&function.identifier.name,
&function.identifier.span,
));
}
let asg_function = Function::init(new_scope, function)?;
asg_function.circuit.replace(Some(circuit));
if asg_function.is_test() {
return Err(AsgConvertError::circuit_test_function(&function.identifier.span));
}
members.insert(function.identifier.name.clone(), CircuitMember::Function(asg_function));
members.insert(
name.name.clone(),
CircuitMember::Variable(new_scope.resolve_ast_type(type_)?),
);
}
}
Ok(circuit)
}
pub(super) fn init_member(
scope: &'a Scope<'a>,
value: &leo_ast::Circuit,
) -> Result<&'a Circuit<'a>, AsgConvertError> {
let new_scope = scope.make_subscope();
let circuits = scope.circuits.borrow();
let circuit = circuits.get(&value.circuit_name.name).unwrap();
new_scope.circuit_self.replace(Some(circuit));
let mut members = circuit.members.borrow_mut();
for member in value.members.iter() {
if let leo_ast::CircuitMember::CircuitFunction(function) = member {
if members.contains_key(&function.identifier.name) {
return Err(AsgConvertError::redefined_circuit_member(
&value.circuit_name.name,
&function.identifier.name,
&function.identifier.span,
));
}
let asg_function = Function::init(new_scope, function)?;
asg_function.circuit.replace(Some(circuit));
if asg_function.is_test() {
return Err(AsgConvertError::circuit_test_function(&function.identifier.span));
}
members.insert(function.identifier.name.clone(), CircuitMember::Function(asg_function));
}
}

View File

@ -37,6 +37,7 @@ use std::cell::{Cell, RefCell};
#[derive(Clone, Copy, PartialEq)]
pub enum FunctionQualifier {
SelfRef,
ConstSelfRef,
MutSelfRef,
Static,
}
@ -89,6 +90,9 @@ impl<'a> Function<'a> {
FunctionInput::SelfKeyword(_) => {
qualifier = FunctionQualifier::SelfRef;
}
FunctionInput::ConstSelfKeyword(_) => {
qualifier = FunctionQualifier::ConstSelfRef;
}
FunctionInput::MutSelfKeyword(_) => {
qualifier = FunctionQualifier::MutSelfRef;
}

View File

@ -243,6 +243,14 @@ impl<'a> Program<'a> {
scope.circuits.borrow_mut().insert(name.name.clone(), asg_circuit);
}
// Second pass for circuit members.
for (name, circuit) in program.circuits.iter() {
assert_eq!(name.name, circuit.circuit_name.name);
let asg_circuit = Circuit::init_member(scope, circuit)?;
scope.circuits.borrow_mut().insert(name.name.clone(), asg_circuit);
}
for (name, function) in program.functions.iter() {
assert_eq!(name.name, function.identifier.name);
let function = Function::init(scope, function)?;

View File

@ -1,3 +1,3 @@
function main() {
let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,3 +1,3 @@
function main() {
let arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions
const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions
}

View File

@ -1,4 +1,4 @@
function main() {
let arr: [u8; (2, 2)] = [[1u8, 1u8],
const arr: [u8; (2, 2)] = [[1u8, 1u8],
[1u8]]; // incorrect dimensions
}

View File

@ -1,3 +1,3 @@
function main() {
let arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions
const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions
}

View File

@ -1,4 +1,4 @@
// Multidimensional array syntax in leo
function main() {
let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,4 +1,4 @@
// Multidimensional array syntax in leo
function main() {
let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let a: [u8; -2] = [0u32; 2];
const a: [u8; -2] = [0u32; 2];
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)
const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering)
const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,7 +1,7 @@
function main() {
let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
let b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer
const b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering)
const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering)
}

View File

@ -1,7 +1,7 @@
function main() {
let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
let b: [u8; (2, 3)] = [0; (2, 3)]; // initializer
const b: [u8; (2, 3)] = [0; (2, 3)]; // initializer
console.assert(a == b);
}

View File

@ -1,3 +1,3 @@
function main() {
let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order)
const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order)
}

View File

@ -1,3 +1,3 @@
function main() {
let a = true && 1u32;
const a = true && 1u32;
}

View File

@ -1,3 +1,3 @@
function main() {
let a = true || 1u32;
const a = true || 1u32;
}

View File

@ -3,5 +3,5 @@ circuit Foo {
}
function main() {
let a = Foo { y: 0u32 };
const a = Foo { y: 0u32 };
}

View File

@ -1,3 +1,3 @@
function main() {
let a = Foo { };
const a = Foo { };
}

View File

@ -5,6 +5,6 @@ circuit Foo {
}
function main() {
let a = Foo { };
let err = a.echoed(1u32);
const a = Foo { };
const err = a.echoed(1u32);
}

View File

@ -5,6 +5,6 @@ circuit Foo {
}
function main() {
let a = Foo { };
let err = a.echo(1u32); // echo is a static function and must be accessed using `::`
const a = Foo { };
const err = a.echo(1u32); // echo is a static function and must be accessed using `::`
}

View File

@ -5,5 +5,5 @@ circuit Foo {
}
function main() {
let err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::`
const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::`
}

View File

@ -5,5 +5,5 @@ circuit Foo {
}
function main() {
let err = Foo::echoed(1u32);
const err = Foo::echoed(1u32);
}

View File

@ -3,7 +3,7 @@ circuit Foo {
}
function main() {
let a = Foo { x: 1u32 };
const a = Foo { x: 1u32 };
let err = a.y;
const err = a.y;
}

View File

@ -60,7 +60,7 @@ fn test_mut_member_function_fail() {
}
function main() {
let a = Foo { };
const a = Foo { };
console.assert(a.echo(1u32) == 1u32);
}"#;

View File

@ -5,7 +5,7 @@ circuit Foo {
}
function main() {
let mut f = Foo { a: 0u8 };
let f = Foo { a: 0u8 };
f.bar = 1u8;
}

View File

@ -9,7 +9,7 @@ circuit Foo {
}
function main() {
let mut f = Foo { a: 0u8 };
let f = Foo { a: 0u8 };
f.set_a(1u8);
}

View File

@ -9,7 +9,7 @@ circuit Foo {
}
function main() {
let mut f = Foo { a: 0u8 };
let f = Foo { a: 0u8 };
f.set_a(1u8);
}

View File

@ -7,7 +7,7 @@ circuit Foo {
}
function main() {
let mut f = Foo { a: 0u8 };
let f = Foo { a: 0u8 };
f.set_a(1u8);
}

View File

@ -3,7 +3,7 @@ circuit Foo {
}
function main() {
let mut f = Foo { a: 0u8 };
let f = Foo { a: 0u8 };
f.bar = 1u8;
}

View File

@ -3,7 +3,7 @@ circuit Foo {
}
function main() {
let f = Foo { a: 0u8 };
const f = Foo { a: 0u8 };
f.a = 1u8;
}

View File

@ -7,6 +7,6 @@ circuit Foo {
}
function main() -> u32 {
let foo = Foo { f: 1u32 };
let err = foo.bar();
const foo = Foo { f: 1u32 };
const err = foo.bar();
}

View File

@ -5,6 +5,6 @@ circuit Foo {
}
function main() {
let foo = Foo { };
let err = foo.bar();
const foo = Foo { };
const err = foo.bar();
}

View File

@ -1,6 +1,6 @@
function foo(a: [u8; 1]) {}
function main() {
let a: [u16; 1] = [1; 1];
const a: [u16; 1] = [1; 1];
foo(a);
}

View File

@ -1,7 +1,7 @@
function main () -> u16 {
if false {
let a = 1u16;
let b = a + 1u16;
const a = 1u16;
const b = a + 1u16;
return b
} else if false {
return 0u16

View File

@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] {
}
function main() {
let b = array_3x2_tuple();
const b = array_3x2_tuple();
}

View File

@ -3,5 +3,5 @@ function array_3x2_nested() -> [u8; (3, 2)] {
}
function main() {
let a = array_3x2_nested();
const a = array_3x2_nested();
}

View File

@ -3,6 +3,6 @@ function foo() -> field {
}
function main() {
let myGlobal = 42field;
let err = foo();
const myGlobal = 42field;
const err = foo();
}

View File

@ -1,3 +1,3 @@
function main() {
let element = (+, +)group;
const element = (+, +)group;
}

View File

@ -1,3 +1,3 @@
function main() {
let element = (_, _)group;
const element = (_, _)group;
}

View File

@ -1,3 +1,3 @@
function main() {
let element = (-, -)group;
const element = (-, -)group;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i128 = 170141183460469231731687303715884105728;
const a: i128 = 170141183460469231731687303715884105728;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i128 = -170141183460469231731687303715884105729;
const a: i128 = -170141183460469231731687303715884105729;
}

View File

@ -1,4 +1,4 @@
function main() {
let a: i128 = -170141183460469231731687303715884105728;
let b = -a;
const a: i128 = -170141183460469231731687303715884105728;
const b = -a;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i16 = 32768;
const a: i16 = 32768;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i16 = -32769;
const a: i16 = -32769;
}

View File

@ -1,4 +1,4 @@
function main() {
let a = -32768i16;
let b = -a;
const a = -32768i16;
const b = -a;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i32 = 2147483648;
const a: i32 = 2147483648;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i32 = -2147483649;
const a: i32 = -2147483649;
}

View File

@ -1,4 +1,4 @@
function main() {
let a = -2147483648i32;
let b = -a;
const a = -2147483648i32;
const b = -a;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i64 = 9223372036854775808;
const a: i64 = 9223372036854775808;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i64 = -9223372036854775809;
const a: i64 = -9223372036854775809;
}

View File

@ -1,4 +1,4 @@
function main() {
let a: i64 = -9223372036854775808;
let b = -a;
const a: i64 = -9223372036854775808;
const b = -a;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i8 = 128;
const a: i8 = 128;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: i8 = -129;
const a: i8 = -129;
}

View File

@ -1,4 +1,4 @@
function main() {
let a = -128i8;
let b = -a;
const a = -128i8;
const b = -a;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u128 = 340282366920938463463374607431768211456;
const a: u128 = 340282366920938463463374607431768211456;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u128 = -1;
const a: u128 = -1;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u16 = 65536;
const a: u16 = 65536;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u16 = -1;
const a: u16 = -1;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u32 = 4294967296;
const a: u32 = 4294967296;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u32 = -1;
const a: u32 = -1;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u64 = 18446744073709551616;
const a: u64 = 18446744073709551616;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u64 = -1;
const a: u64 = -1;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u8 = 256;
const a: u8 = 256;
}

View File

@ -1,3 +1,3 @@
function main() {
let a: u8 = -1;
const a: u8 = -1;
}

View File

@ -1,5 +1,5 @@
// Arrays are immutable by default.
function main() {
let a = [1u32];
const a = [1u32];
a[0] = 0;
}

View File

@ -4,6 +4,6 @@ circuit Foo {
}
function main() {
let a = Foo { x: 1 };
const a = Foo { x: 1 };
a.x = 0;
}

View File

@ -4,6 +4,6 @@ circuit Foo {
}
function main() {
let mut a = Foo { x: 1 };
let a = Foo { x: 1 };
a.bar = 0;
}

View File

@ -4,6 +4,6 @@ circuit Foo {
}
function main() {
let mut a = Foo { x: 1 };
let a = Foo { x: 1 };
a.bar = 0;
}

View File

@ -1,5 +1,5 @@
// Let variables are immutable by default.
function main() {
let a = 1u32;
const a = 1u32;
a = 0;
}

View File

@ -1,4 +1,4 @@
// Function input are immutable by default.
function main(a: bool) {
// Const function input are immutable.
function main(const a: bool) {
a = false;
}

View File

@ -1,5 +1,5 @@
// Variables are immutable by default.
function main() {
let a = 1u32;
const a = 1u32;
a = 0;
}

View File

@ -1,3 +0,0 @@
function main() {
const x = 1u32;
}

View File

@ -0,0 +1,3 @@
function main() {
let mut x = 1u32;
}

View File

@ -23,7 +23,7 @@ fn test_num_returns_fail() {
}
#[test]
fn test_const_declaration_fail() {
let program_string = include_str!("const_declaration_fail.leo");
fn test_let_mut_declaration_fail() {
let program_string = include_str!("let_mut_declaration_fail.leo");
load_asg(program_string).err().unwrap();
}

View File

@ -1,6 +1,6 @@
function main() {
let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
console.assert(address_1 == address_2);
}

View File

@ -1,3 +1,3 @@
function main() {
let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,3 +1,3 @@
function main() {
let public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
}

View File

@ -1,5 +1,5 @@
function main(owner: address) {
let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
console.assert(owner == sender);
}

View File

@ -1,8 +1,8 @@
function main(s: bool, c: address) {
let a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
let b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r);
const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r);
let r = s? a: b;
const r = s? a: b;
console.assert(r == c);
}

View File

@ -1,3 +1,3 @@
function main() {
let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
}

View File

@ -1,6 +1,6 @@
function main(){
let a = [1u8, 2u8, 3u8, 4];
let b = [1u8, 2u8, 3, 4u8];
let c = [1u8, 2, 3u8, 4u8];
let d = [1, 2u8, 3u8, 4u8];
const a = [1u8, 2u8, 3u8, 4];
const b = [1u8, 2u8, 3, 4u8];
const c = [1u8, 2, 3u8, 4u8];
const d = [1, 2u8, 3u8, 4u8];
}

View File

@ -1,5 +1,5 @@
function main() {
let x = 0u8;
let a = [0u8; 4];
const x = 0u8;
const a = [0u8; 4];
console.assert(a[x] == 0);
}

View File

@ -1,7 +1,7 @@
function main() {
let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)];
const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)];
let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2];
const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2];
console.assert(a == b);
}

View File

@ -1,8 +1,8 @@
// Multidimensional array syntax in leo
function main() {
let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline
const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline
let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer
const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer
console.assert(a == b);
}

View File

@ -1,6 +1,6 @@
// `{from}..{to}` copies the elements of one array into another exclusively
function main(a: [u8; 3]) {
let b = [1u8; 4];
const b = [1u8; 4];
console.assert(a == b[0..3]);
}

View File

@ -1,6 +1,6 @@
// `{from}..{to}` copies the elements of one array into another exclusively
function main(a: [u8; 3]) {
let b = [1u8; 4];
const b = [1u8; 4];
console.assert(a == b[0u8..3i8]);
}

View File

@ -1,8 +1,8 @@
function main() {
let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
let expected: [u32; 2] = [0, 1];
const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
const expected: [u32; 2] = [0, 1];
let actual = arr[..2]; // Should produce [0, 1]
const actual = arr[..2]; // Should produce [0, 1]
console.assert(expected == actual);
}

View File

@ -1,7 +1,7 @@
// A spread operator `...` copies the elements of one array into another
function main(a: [u8; 3]) {
let b = [1u8, 1u8];
let c = [1u8, ...b];
const b = [1u8, 1u8];
const c = [1u8, ...b];
console.assert(a == c);
}

View File

@ -1,8 +1,8 @@
// Multidimensional array syntax in leo
function main() {
let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline
const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline
let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer
const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer
console.assert(a == b);
}

View File

@ -1,5 +1,5 @@
function main(a: [[u8; 2]; 3]) {
let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline
console.assert(a == b);
}

View File

@ -1,5 +1,5 @@
function main(a: [[[u8; 2]; 3]; 4]) {
let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline

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