fix(check): only disallow ml_result in data

This commit is contained in:
rvcas 2024-02-29 11:19:26 -05:00
parent d18caaeecb
commit ff5491caa0
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
3 changed files with 29 additions and 2 deletions

View File

@ -153,7 +153,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
MILLER_LOOP_RESULT.to_string(),
TypeConstructor {
parameters: vec![],
tipo: int(),
tipo: miller_loop_result(),
location: Span::empty(),
module: "".to_string(),
public: true,

View File

@ -50,6 +50,33 @@ fn check_validator(
check_module(ast, ModuleKind::Validator)
}
#[test]
fn bls12_381_elements_in_data_type() {
let source_code = r#"
type Datum {
D0(G1Element)
D1(G2Element)
}
"#;
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn bls12_381_ml_result_in_data_type() {
let source_code = r#"
type Datum {
thing: MillerLoopResult
}
"#;
let res = check(parse(source_code));
dbg!(&res);
assert!(matches!(res, Err((_, Error::IllegalTypeInData { .. }))))
}
#[test]
fn validator_illegal_return_type() {
let source_code = r#"

View File

@ -546,7 +546,7 @@ fn infer_definition(
});
}
if tipo.is_bls381_12_g1() || tipo.is_bls381_12_g2() || tipo.is_ml_result() {
if tipo.is_ml_result() {
return Err(Error::IllegalTypeInData {
location: *location,
tipo: tipo.clone(),