mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-01 10:17:30 +03:00
deprecate let mut, undeprecate const, let is now mutable by default
This commit is contained in:
parent
039c295b20
commit
b50919085b
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
}
|
@ -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
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let arr: [u8; (2, 2)] = [[1u8, 1u8],
|
||||
const arr: [u8; (2, 2)] = [[1u8, 1u8],
|
||||
[1u8]]; // incorrect dimensions
|
||||
}
|
@ -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
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: [u8; -2] = [0u32; 2];
|
||||
const a: [u8; -2] = [0u32; 2];
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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);
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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);
|
||||
}
|
@ -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)
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a = true && 1u32;
|
||||
const a = true && 1u32;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a = true || 1u32;
|
||||
const a = true || 1u32;
|
||||
}
|
@ -3,5 +3,5 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let a = Foo { y: 0u32 };
|
||||
const a = Foo { y: 0u32 };
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a = Foo { };
|
||||
const a = Foo { };
|
||||
}
|
@ -5,6 +5,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let a = Foo { };
|
||||
let err = a.echoed(1u32);
|
||||
const a = Foo { };
|
||||
const err = a.echoed(1u32);
|
||||
}
|
@ -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 `::`
|
||||
}
|
@ -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 `::`
|
||||
}
|
@ -5,5 +5,5 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let err = Foo::echoed(1u32);
|
||||
const err = Foo::echoed(1u32);
|
||||
}
|
@ -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;
|
||||
}
|
@ -60,7 +60,7 @@ fn test_mut_member_function_fail() {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let a = Foo { };
|
||||
const a = Foo { };
|
||||
|
||||
console.assert(a.echo(1u32) == 1u32);
|
||||
}"#;
|
||||
|
@ -5,7 +5,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut f = Foo { a: 0u8 };
|
||||
let f = Foo { a: 0u8 };
|
||||
|
||||
f.bar = 1u8;
|
||||
}
|
@ -9,7 +9,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut f = Foo { a: 0u8 };
|
||||
let f = Foo { a: 0u8 };
|
||||
|
||||
f.set_a(1u8);
|
||||
}
|
@ -9,7 +9,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut f = Foo { a: 0u8 };
|
||||
let f = Foo { a: 0u8 };
|
||||
|
||||
f.set_a(1u8);
|
||||
}
|
@ -7,7 +7,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut f = Foo { a: 0u8 };
|
||||
let f = Foo { a: 0u8 };
|
||||
|
||||
f.set_a(1u8);
|
||||
}
|
@ -3,7 +3,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut f = Foo { a: 0u8 };
|
||||
let f = Foo { a: 0u8 };
|
||||
|
||||
f.bar = 1u8;
|
||||
}
|
@ -3,7 +3,7 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let f = Foo { a: 0u8 };
|
||||
const f = Foo { a: 0u8 };
|
||||
|
||||
f.a = 1u8;
|
||||
}
|
@ -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();
|
||||
}
|
@ -5,6 +5,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let foo = Foo { };
|
||||
let err = foo.bar();
|
||||
const foo = Foo { };
|
||||
const err = foo.bar();
|
||||
}
|
@ -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);
|
||||
}
|
@ -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
|
||||
|
@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let b = array_3x2_tuple();
|
||||
const b = array_3x2_tuple();
|
||||
}
|
@ -3,5 +3,5 @@ function array_3x2_nested() -> [u8; (3, 2)] {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let a = array_3x2_nested();
|
||||
const a = array_3x2_nested();
|
||||
}
|
@ -3,6 +3,6 @@ function foo() -> field {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let myGlobal = 42field;
|
||||
let err = foo();
|
||||
const myGlobal = 42field;
|
||||
const err = foo();
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let element = (+, +)group;
|
||||
const element = (+, +)group;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let element = (_, _)group;
|
||||
const element = (_, _)group;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let element = (-, -)group;
|
||||
const element = (-, -)group;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i128 = 170141183460469231731687303715884105728;
|
||||
const a: i128 = 170141183460469231731687303715884105728;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i128 = -170141183460469231731687303715884105729;
|
||||
const a: i128 = -170141183460469231731687303715884105729;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let a: i128 = -170141183460469231731687303715884105728;
|
||||
let b = -a;
|
||||
const a: i128 = -170141183460469231731687303715884105728;
|
||||
const b = -a;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i16 = 32768;
|
||||
const a: i16 = 32768;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i16 = -32769;
|
||||
const a: i16 = -32769;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let a = -32768i16;
|
||||
let b = -a;
|
||||
const a = -32768i16;
|
||||
const b = -a;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i32 = 2147483648;
|
||||
const a: i32 = 2147483648;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i32 = -2147483649;
|
||||
const a: i32 = -2147483649;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let a = -2147483648i32;
|
||||
let b = -a;
|
||||
const a = -2147483648i32;
|
||||
const b = -a;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i64 = 9223372036854775808;
|
||||
const a: i64 = 9223372036854775808;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i64 = -9223372036854775809;
|
||||
const a: i64 = -9223372036854775809;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let a: i64 = -9223372036854775808;
|
||||
let b = -a;
|
||||
const a: i64 = -9223372036854775808;
|
||||
const b = -a;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i8 = 128;
|
||||
const a: i8 = 128;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: i8 = -129;
|
||||
const a: i8 = -129;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function main() {
|
||||
let a = -128i8;
|
||||
let b = -a;
|
||||
const a = -128i8;
|
||||
const b = -a;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u128 = 340282366920938463463374607431768211456;
|
||||
const a: u128 = 340282366920938463463374607431768211456;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u128 = -1;
|
||||
const a: u128 = -1;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u16 = 65536;
|
||||
const a: u16 = 65536;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u16 = -1;
|
||||
const a: u16 = -1;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u32 = 4294967296;
|
||||
const a: u32 = 4294967296;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u32 = -1;
|
||||
const a: u32 = -1;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u64 = 18446744073709551616;
|
||||
const a: u64 = 18446744073709551616;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u64 = -1;
|
||||
const a: u64 = -1;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u8 = 256;
|
||||
const a: u8 = 256;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let a: u8 = -1;
|
||||
const a: u8 = -1;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Arrays are immutable by default.
|
||||
function main() {
|
||||
let a = [1u32];
|
||||
const a = [1u32];
|
||||
a[0] = 0;
|
||||
}
|
@ -4,6 +4,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let a = Foo { x: 1 };
|
||||
const a = Foo { x: 1 };
|
||||
a.x = 0;
|
||||
}
|
@ -4,6 +4,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut a = Foo { x: 1 };
|
||||
let a = Foo { x: 1 };
|
||||
a.bar = 0;
|
||||
}
|
@ -4,6 +4,6 @@ circuit Foo {
|
||||
}
|
||||
|
||||
function main() {
|
||||
let mut a = Foo { x: 1 };
|
||||
let a = Foo { x: 1 };
|
||||
a.bar = 0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Let variables are immutable by default.
|
||||
function main() {
|
||||
let a = 1u32;
|
||||
const a = 1u32;
|
||||
a = 0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Variables are immutable by default.
|
||||
function main() {
|
||||
let a = 1u32;
|
||||
const a = 1u32;
|
||||
a = 0;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
function main() {
|
||||
const x = 1u32;
|
||||
}
|
3
asg/tests/fail/statements/let_mut_declaration_fail.leo
Normal file
3
asg/tests/fail/statements/let_mut_declaration_fail.leo
Normal file
@ -0,0 +1,3 @@
|
||||
function main() {
|
||||
let mut x = 1u32;
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
function main(owner: address) {
|
||||
let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
|
||||
const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
|
||||
|
||||
console.assert(owner == sender);
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
function main() {
|
||||
let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
|
||||
const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8);
|
||||
}
|
@ -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];
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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]);
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
function main() {
|
||||
let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
const a = [[[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
|
||||
|
||||
let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer
|
||||
const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -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);
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
function main() {
|
||||
let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
|
||||
const a = [[[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
|
||||
|
||||
let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer
|
||||
const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
@ -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; (3, 2)] = [[0; 2]; 3]; // initializer
|
||||
const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer
|
||||
|
||||
console.assert(a == b);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user