Merge pull request #794 from AleoHQ/feature/constant-mutable-declarations

Feature/constant mutable declarations
This commit is contained in:
Collin Chin 2021-03-25 23:23:13 -07:00 committed by GitHub
commit 9bc53eb594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
712 changed files with 1513 additions and 1382 deletions

View File

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

View File

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

View File

@ -1,3 +1,3 @@
function main() { 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() { function main() {
let arr: [u8; (2, 2)] = [[1u8, 1u8], const arr: [u8; (2, 2)] = [[1u8, 1u8],
[1u8]]; // incorrect dimensions [1u8]]; // incorrect dimensions
} }

View File

@ -1,3 +1,3 @@
function main() { 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 // Multidimensional array syntax in leo
function main() { 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 // Multidimensional array syntax in leo
function main() { 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() { function main() {
let a: [u8; -2] = [0u32; 2]; const a: [u8; -2] = [0u32; 2];
} }

View File

@ -1,3 +1,3 @@
function main() { 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() { 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() { 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() { 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() { 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() { 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); console.assert(a == b);
} }

View File

@ -1,3 +1,3 @@
function main() { 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() { 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() { 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); console.assert(a == b);
} }

View File

@ -1,3 +1,3 @@
function main() { 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() { function main() {
let a = true && 1u32; const a = true && 1u32;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ circuit Foo {
} }
function main() { 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() { function main() {
let a = Foo { }; const a = Foo { };
console.assert(a.echo(1u32) == 1u32); console.assert(a.echo(1u32) == 1u32);
}"#; }"#;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] {
} }
function main() { 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() { function main() {
let a = array_3x2_nested(); const a = array_3x2_nested();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
// Variables are immutable by default. // Variables are immutable by default.
function main() { function main() {
let a = 1u32; const a = 1u32;
a = 0; 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] #[test]
fn test_const_declaration_fail() { fn test_let_mut_declaration_fail() {
let program_string = include_str!("const_declaration_fail.leo"); let program_string = include_str!("let_mut_declaration_fail.leo");
load_asg(program_string).err().unwrap(); load_asg(program_string).err().unwrap();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
function main() { 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); console.assert(a == b);
} }

View File

@ -1,8 +1,8 @@
// Multidimensional array syntax in leo // Multidimensional array syntax in leo
function main() { 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); console.assert(a == b);
} }

View File

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

View File

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

View File

@ -1,8 +1,8 @@
function main() { function main() {
let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
let expected: [u32; 2] = [0, 1]; 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); console.assert(expected == actual);
} }

View File

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

View File

@ -1,8 +1,8 @@
// Multidimensional array syntax in leo // Multidimensional array syntax in leo
function main() { 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); console.assert(a == b);
} }

View File

@ -1,5 +1,5 @@
function main(a: [[u8; 2]; 3]) { 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); console.assert(a == b);
} }

View File

@ -1,5 +1,5 @@
function main(a: [[[u8; 2]; 3]; 4]) { 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]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline

View File

@ -1,7 +1,7 @@
function main() { 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); console.assert(a == b);
} }

View File

@ -1,10 +1,10 @@
function main() { 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]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline [[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); console.assert(a == b);
} }

View File

@ -1,7 +1,7 @@
function main() { 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); console.assert(a == b);
} }

View File

@ -1,10 +1,10 @@
function main() { 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]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]],
[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline [[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); console.assert(a == b);
} }

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