Fix implementation

This commit is contained in:
Pranav Gaddamadugu 2023-06-23 20:35:42 -04:00
parent 9b7a4ba456
commit 8b4552efd5
7 changed files with 66 additions and 4 deletions

View File

@ -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();

View File

@ -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)
}
}
}

View 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: ""

View 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: ""

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition main(a: group) -> field {
return group::to_x_coordinate(a);
}
}

View File

@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/
program test.aleo {
transition main(a: group) -> field {
return group::to_y_coordinate(a);
}
}

View 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);
}
}