mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-13 08:47:17 +03:00
Fix implementation
This commit is contained in:
parent
9b7a4ba456
commit
8b4552efd5
@ -299,7 +299,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
};
|
||||
|
||||
// Construct the instruction.
|
||||
let (destination, instruction) = match input.ty {
|
||||
let (destination, instruction) = match &input.ty {
|
||||
Type::Identifier(Identifier { name: sym::BHP256, .. }) => {
|
||||
construct_simple_function_call(&input.name, "bhp256", arguments)
|
||||
}
|
||||
@ -357,7 +357,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
}
|
||||
_ => unreachable!("The only variants of Mapping are get, get_or, and set"),
|
||||
},
|
||||
Type::Group => {
|
||||
Type::Identifier(Identifier { name: sym::group, .. }) => {
|
||||
match input.name {
|
||||
Identifier { name: sym::to_x_coordinate, .. } => {
|
||||
let mut instruction = " cast".to_string();
|
||||
|
@ -863,8 +863,8 @@ impl<'a> TypeChecker<'a> {
|
||||
}
|
||||
CoreFunction::GroupToXCoordinate | CoreFunction::GroupToYCoordinate => {
|
||||
// Check that the first argument is a group.
|
||||
self.assert_scalar_type(&arguments[0].0, arguments[0].1);
|
||||
Some(Type::Group)
|
||||
self.assert_group_type(&arguments[0].0, arguments[0].1);
|
||||
Some(Type::Field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
tests/expectations/compiler/group/to_x_coordinate.out
Normal file
12
tests/expectations/compiler/group/to_x_coordinate.out
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_ast: 466c3da8bb0bc3711a3071784e06a475abbd95c4afa46ce2149bdaf8fbabe6e4
|
||||
unrolled_ast: 466c3da8bb0bc3711a3071784e06a475abbd95c4afa46ce2149bdaf8fbabe6e4
|
||||
ssa_ast: 9455d0f91c594cacc93cba0358e1d40017f65765b59b18a341ea2966b4ecb1df
|
||||
flattened_ast: b0caf68c1a6fe8ee511a80829ab30c35630daa28f86b4be4bf25adf1a0a367a8
|
||||
inlined_ast: b0caf68c1a6fe8ee511a80829ab30c35630daa28f86b4be4bf25adf1a0a367a8
|
||||
dce_ast: b0caf68c1a6fe8ee511a80829ab30c35630daa28f86b4be4bf25adf1a0a367a8
|
||||
bytecode: 51e95e10668242bec30e9917715d9856da632e933c33207ee41c5ed38d6366aa
|
||||
warnings: ""
|
12
tests/expectations/compiler/group/to_y_coordinate.out
Normal file
12
tests/expectations/compiler/group/to_y_coordinate.out
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_ast: 6cc132d16506cefce980b7ecb6637bc89a6db79e90073c307dbb75a2a25e3251
|
||||
unrolled_ast: 6cc132d16506cefce980b7ecb6637bc89a6db79e90073c307dbb75a2a25e3251
|
||||
ssa_ast: 8b8a2daa8b7e32c23f2d3290ab3557b7b6d98afeb2ae55c35795de7e8180ef79
|
||||
flattened_ast: 00b4b6055c4035a3c016a88afa60f8504dec8542ad6413bd8340f75ce60564b2
|
||||
inlined_ast: 00b4b6055c4035a3c016a88afa60f8504dec8542ad6413bd8340f75ce60564b2
|
||||
dce_ast: 00b4b6055c4035a3c016a88afa60f8504dec8542ad6413bd8340f75ce60564b2
|
||||
bytecode: ea2e94f0f589fac4565040575643b1b7cd7813fe513d5b09b17c191bbf0f727e
|
||||
warnings: ""
|
10
tests/tests/compiler/group/to_x_coordinate.leo
Normal file
10
tests/tests/compiler/group/to_x_coordinate.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition main(a: group) -> field {
|
||||
return group::to_x_coordinate(a);
|
||||
}
|
||||
}
|
10
tests/tests/compiler/group/to_y_coordinate.leo
Normal file
10
tests/tests/compiler/group/to_y_coordinate.leo
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition main(a: group) -> field {
|
||||
return group::to_y_coordinate(a);
|
||||
}
|
||||
}
|
18
tests/tests/execution/group_operations.leo
Normal file
18
tests/tests/execution/group_operations.leo
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
namespace: Execute
|
||||
expectation: Pass
|
||||
cases:
|
||||
main:
|
||||
- input: ["0group"]
|
||||
- input: ["2group"]
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition main(a: group) -> (field, field) {
|
||||
let b: field = group::to_x_coordinate(a);
|
||||
let c: field = a as field;
|
||||
assert_eq(b, c);
|
||||
let d: field = group::to_y_coordinate(a);
|
||||
return (b, d);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user