fix field/group addition

This commit is contained in:
Protryon 2021-02-11 09:05:43 -08:00
parent 20a046bbbb
commit 198230d604
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");