mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-24 02:42:21 +03:00
rename balance -> gates
This commit is contained in:
parent
4d809e82a6
commit
b5a2790375
@ -61,7 +61,7 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||
});
|
||||
}
|
||||
|
||||
// For records, enforce presence of `owner: Address` and `balance: u64` members.
|
||||
// For records, enforce presence of `owner: Address` and `gates: u64` members.
|
||||
if input.is_record {
|
||||
let check_has_field = |need, expected_ty: Type| match input
|
||||
.members
|
||||
@ -79,7 +79,7 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
|
||||
}
|
||||
};
|
||||
check_has_field(sym::owner, Type::Address);
|
||||
check_has_field(sym::balance, Type::IntegerType(IntegerType::U64));
|
||||
check_has_field(sym::gates, Type::IntegerType(IntegerType::U64));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -10,7 +10,7 @@ record Token {
|
||||
function mint(owner: address, amount: u64) -> Token {
|
||||
return Token {
|
||||
owner,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount,
|
||||
};
|
||||
}
|
||||
@ -19,5 +19,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -4,7 +4,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -19,7 +19,7 @@ circuit Receiver {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
owner: r0,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r1,
|
||||
};
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ symbols! {
|
||||
public,
|
||||
private,
|
||||
owner,
|
||||
balance,
|
||||
gates,
|
||||
|
||||
// todo: remove these.
|
||||
CONTAINER_PSEUDO_CIRCUIT: "$InputContainer",
|
||||
|
@ -3,9 +3,9 @@ namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
// This record does define the `balance` variable but with the wrong type.
|
||||
// This record does define the `gates` variable but with the wrong type.
|
||||
record Token {
|
||||
balance: address,
|
||||
gates: address,
|
||||
owner: address,
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address, // Cannot define two record variables with the same name.
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
owner: r0,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r1,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(owner: address, amount: u64) -> Token {
|
||||
return Token {
|
||||
owner,
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
owner: r1, // This variable should be type address.
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r0, // This variable should be type u64.
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -7,7 +7,7 @@ record Token {
|
||||
// The token owner.
|
||||
owner: address,
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
@ -15,7 +15,7 @@ record Token {
|
||||
function mint(r0: address, r1: u64) -> Token {
|
||||
return Token {
|
||||
sender: r0, // This variable should be named `owner`.
|
||||
balance: 0u64,
|
||||
gates: 0u64,
|
||||
amount: r1,
|
||||
};
|
||||
}
|
||||
@ -24,5 +24,5 @@ function main(x: address) -> u64 {
|
||||
const c: u64 = 1u64;
|
||||
let t: Token = mint(x, c);
|
||||
|
||||
return t.balance;
|
||||
return t.gates;
|
||||
}
|
@ -6,7 +6,7 @@ expectation: Fail
|
||||
// This record does not define the `owner` variable required for a record type.
|
||||
record Token {
|
||||
// The Aleo balance (in gates).
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
// The token amount.
|
||||
amount: u64,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ expectation: Fail
|
||||
|
||||
// This record does define the `owner` variable but with the wrong type.
|
||||
record Token {
|
||||
balance: u64,
|
||||
gates: u64,
|
||||
owner: bool,
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372024]: The field `balance` in a `record` must have type `u64`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | balance: address,\n 6 | owner: address,\n 7 | }\n | ^\n"
|
||||
- "Error [ETYC0372024]: The field `gates` in a `record` must have type `u64`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: address,\n 6 | owner: address,\n 7 | }\n | ^\n"
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: ed6dbb2a60da9a91da4b3845e3919b0520666cf4d7223e5634e1e8e38dd9243d
|
||||
symbol_table: c49906bcded430e36886bfabc35c5740e4657ac82761b80b871f6d19ec6d9dda
|
||||
initial_ast: 28c94d00e43d55f13c723745d098509445d42293b47350f029b7804fa7c8d9b0
|
||||
symbol_table: 66db4d9c92e4f1000de18b6e446cde1476ab527f1e368dcb1bc500c7bf401f2b
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372020]: Record Token defined with more than one variable with the same name.\n --> compiler-test:3:1\n |\n 3 | record Token {\n 4 | // The token owner.\n 5 | owner: address,\n 6 | // The token owner.\n 7 | owner: address, // Cannot define two record variables with the same name.\n 8 | // The Aleo balance (in gates).\n 9 | balance: u64,\n 10 | // The token amount.\n 11 | amount: u64,\n 12 | }\n | ^\n"
|
||||
- "Error [ETYC0372020]: Record Token defined with more than one variable with the same name.\n --> compiler-test:3:1\n |\n 3 | record Token {\n 4 | // The token owner.\n 5 | owner: address,\n 6 | // The token owner.\n 7 | owner: address, // Cannot define two record variables with the same name.\n 8 | // The Aleo balance (in gates).\n 9 | gates: u64,\n 10 | // The token amount.\n 11 | amount: u64,\n 12 | }\n | ^\n"
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: cc9fdc5ee476d5c8930260c5fc50c968915434892180f0084f15cd69b905dc20
|
||||
symbol_table: 926c2f494fbb7914574e7b95bedd8992eaf028143e19bebcdcdf474fcb5eb1c5
|
||||
initial_ast: a9ac59f8fe171e7565cf65a0c70120dc3f629faafea2694dacb5c9e5943fcb2c
|
||||
symbol_table: bef5b8640f241c578a71afbe1c8f6f02ba49d48180349ddb335d4ea5fb61919c
|
||||
|
@ -4,5 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: no input
|
||||
initial_ast: c765de9e29d4ca9bd9ba2f7a5ee72c2e4c8278948d32a6c9a441f5eacde564ea
|
||||
symbol_table: de1844db50840db6655f51a2903da4287d51c03a6e693843bdd6be95c6d627f8
|
||||
initial_ast: 02761b2fb9fd0da7e266fca8ee04832fa4cb4f3a0868ab2d4e7830d319affc4c
|
||||
symbol_table: f7a86c3add706babf7dffb52750bccdd245c1950599b2d40a076c6d6c61d75c5
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372023]: The `record` type requires the variable `owner: address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | // The Aleo balance (in gates).\n 6 | balance: u64,\n 7 | // The token amount.\n 8 | amount: u64,\n 9 | }\n | ^\n"
|
||||
- "Error [ETYC0372023]: The `record` type requires the variable `owner: address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | // The Aleo balance (in gates).\n 6 | gates: u64,\n 7 | // The token amount.\n 8 | amount: u64,\n 9 | }\n | ^\n"
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372024]: The field `owner` in a `record` must have type `address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | balance: u64,\n 6 | owner: bool,\n 7 | }\n | ^\n"
|
||||
- "Error [ETYC0372024]: The field `owner` in a `record` must have type `address`.\n --> compiler-test:4:1\n |\n 4 | record Token {\n 5 | gates: u64,\n 6 | owner: bool,\n 7 | }\n | ^\n"
|
||||
|
Loading…
Reference in New Issue
Block a user