mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 02:24:15 +03:00
removes <, <=, >, >= for address type
This commit is contained in:
parent
bf8ca5abc4
commit
c16a93ab44
@ -326,13 +326,9 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
let t2 = self.visit_expression(&input.right, &None);
|
||||
|
||||
match (t1, t2) {
|
||||
(Some(Type::Address), t2) => {
|
||||
// Assert rhs is address.
|
||||
self.assert_expected_type(&t2, Type::Address, input.left.span());
|
||||
}
|
||||
(t1, Some(Type::Address)) => {
|
||||
// Assert lhs is address.
|
||||
self.assert_expected_type(&t1, Type::Address, input.right.span());
|
||||
(Some(Type::Address), _) | (_, Some(Type::Address)) => {
|
||||
// Emit an error for address comparison.
|
||||
self.handler.emit_err(TypeCheckerError::compare_address(input.span()).into());
|
||||
}
|
||||
(Some(Type::Field), t2) => {
|
||||
// Assert rhs is field.
|
||||
|
@ -264,4 +264,11 @@ create_messages!(
|
||||
msg: format!("The field `{name}` in a `record` must have type `{type_}`."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
compare_address {
|
||||
args: (),
|
||||
msg: format!("Comparison `<, <=, >, >=` is not supported for the address type."),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ namespace: Compile
|
||||
expectation: Pass
|
||||
input_file:
|
||||
- inputs/address1.in
|
||||
- inputs/address2.in
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
|
12
tests/compiler/address/gt_fail.leo
Normal file
12
tests/compiler/address/gt_fail.leo
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/address1.in
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender: address = aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta;
|
||||
|
||||
return x > sender;
|
||||
}
|
12
tests/compiler/address/gte_fail.leo
Normal file
12
tests/compiler/address/gte_fail.leo
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/address1.in
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender: address = aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta;
|
||||
|
||||
return x >= sender;
|
||||
}
|
12
tests/compiler/address/lt_fail.leo
Normal file
12
tests/compiler/address/lt_fail.leo
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/address1.in
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender: address = aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta;
|
||||
|
||||
return x < sender;
|
||||
}
|
12
tests/compiler/address/lte_fail.leo
Normal file
12
tests/compiler/address/lte_fail.leo
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
input_file:
|
||||
- inputs/address1.in
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender: address = aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta;
|
||||
|
||||
return x <= sender;
|
||||
}
|
@ -4,6 +4,5 @@ expectation: Pass
|
||||
outputs:
|
||||
- output:
|
||||
- initial_input_ast: 03e9df3bd1409f4af9e2a7f55130bc52f27d41f32a624ffa27f0ab114bf6fbf4
|
||||
- initial_input_ast: 9a0d83e67799f28ec6613d9aac9d921aea81eebb68c9682de33c69036c4a924f
|
||||
initial_ast: ea3c9a73110ccc7684863543cf563ec78349402c460a75317b776af11d46f781
|
||||
symbol_table: 18395a136ea969d319cc4c12c59bb7a590a1b11339375240700d7c87f26b1d5d
|
||||
|
5
tests/expectations/compiler/compiler/address/gt_fail.out
Normal file
5
tests/expectations/compiler/compiler/address/gt_fail.out
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372025]: Comparison `<, <=, >, >=` is not supported for the address type.\n --> compiler-test:6:12\n |\n 6 | return x > sender;\n | ^^^^^^^^^^\n"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372025]: Comparison `<, <=, >, >=` is not supported for the address type.\n --> compiler-test:6:12\n |\n 6 | return x >= sender;\n | ^^^^^^^^^^^\n"
|
5
tests/expectations/compiler/compiler/address/lt_fail.out
Normal file
5
tests/expectations/compiler/compiler/address/lt_fail.out
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372025]: Comparison `<, <=, >, >=` is not supported for the address type.\n --> compiler-test:6:12\n |\n 6 | return x < sender;\n | ^^^^^^^^^^\n"
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372025]: Comparison `<, <=, >, >=` is not supported for the address type.\n --> compiler-test:6:12\n |\n 6 | return x <= sender;\n | ^^^^^^^^^^^\n"
|
Loading…
Reference in New Issue
Block a user