fix(check): only disallow ml_result in data
This commit is contained in:
parent
d18caaeecb
commit
ff5491caa0
|
@ -153,7 +153,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
||||||
MILLER_LOOP_RESULT.to_string(),
|
MILLER_LOOP_RESULT.to_string(),
|
||||||
TypeConstructor {
|
TypeConstructor {
|
||||||
parameters: vec![],
|
parameters: vec![],
|
||||||
tipo: int(),
|
tipo: miller_loop_result(),
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
module: "".to_string(),
|
module: "".to_string(),
|
||||||
public: true,
|
public: true,
|
||||||
|
|
|
@ -50,6 +50,33 @@ fn check_validator(
|
||||||
check_module(ast, ModuleKind::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]
|
#[test]
|
||||||
fn validator_illegal_return_type() {
|
fn validator_illegal_return_type() {
|
||||||
let source_code = r#"
|
let source_code = r#"
|
||||||
|
|
|
@ -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 {
|
return Err(Error::IllegalTypeInData {
|
||||||
location: *location,
|
location: *location,
|
||||||
tipo: tipo.clone(),
|
tipo: tipo.clone(),
|
||||||
|
|
Loading…
Reference in New Issue