Merge pull request #654 from AleoHQ/field-group-fix

Fix field/group addition
This commit is contained in:
Collin Chin 2021-02-11 17:43:32 -08:00 committed by GitHub
commit 29fa7cf19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -134,10 +134,12 @@ impl FromAst<leo_ast::BinaryExpression> for BinaryExpression {
},
BinaryOperationClass::Numeric => match expected_type {
Some(x @ PartialType::Integer(_, _)) => Some(x),
Some(x @ PartialType::Type(Type::Field)) => Some(x),
Some(x @ PartialType::Type(Type::Group)) => Some(x),
Some(x) => {
return Err(AsgConvertError::unexpected_type(
&x.to_string(),
Some("integer"),
Some("integer, field, or group"),
&value.span,
));
}

View File

@ -28,6 +28,16 @@ fn test_add() {
load_asg(program_string).unwrap();
}
#[test]
fn test_add_explicit() {
let program_string = r#"
function main() {
let c: field = 0field + 1field;
}
"#;
load_asg(program_string).unwrap();
}
#[test]
fn test_sub() {
let program_string = include_str!("sub.leo");

View File

@ -104,6 +104,16 @@ fn test_add() {
load_asg(program_string).unwrap();
}
#[test]
fn test_add_explicit() {
let program_string = r#"
function main() {
let c: group = 0group + 1group;
}
"#;
load_asg(program_string).unwrap();
}
#[test]
fn test_sub() {
let program_string = include_str!("sub.leo");