fix circuit resolution

This commit is contained in:
Protryon 2021-02-11 11:59:14 -08:00
parent 20a046bbbb
commit b0de29e275
2 changed files with 19 additions and 10 deletions

View File

@ -218,21 +218,17 @@ impl InnerScope {
.collect::<Result<Vec<_>, AsgConvertError>>()?, .collect::<Result<Vec<_>, AsgConvertError>>()?,
), ),
Circuit(name) if name.name == "Self" => Type::Circuit( Circuit(name) if name.name == "Self" => Type::Circuit(
self.circuit_self self.resolve_circuit_self()
.clone()
.ok_or_else(|| AsgConvertError::unresolved_circuit(&name.name, &name.span))?, .ok_or_else(|| AsgConvertError::unresolved_circuit(&name.name, &name.span))?,
), ),
Circuit(name) => Type::Circuit(
self.circuits
.get(&name.name)
.ok_or_else(|| AsgConvertError::unresolved_circuit(&name.name, &name.span))?
.clone(),
),
SelfType => Type::Circuit( SelfType => Type::Circuit(
self.circuit_self self.resolve_circuit_self()
.clone()
.ok_or_else(AsgConvertError::reference_self_outside_circuit)?, .ok_or_else(AsgConvertError::reference_self_outside_circuit)?,
), ),
Circuit(name) => Type::Circuit(
self.resolve_circuit(&name.name)
.ok_or_else(|| AsgConvertError::unresolved_circuit(&name.name, &name.span))?,
),
}) })
} }
} }

View File

@ -120,3 +120,16 @@ fn test_define_circuit_inside_circuit_function() {
let program_string = include_str!("define_circuit_inside_circuit_function.leo"); let program_string = include_str!("define_circuit_inside_circuit_function.leo");
load_asg(program_string).unwrap(); load_asg(program_string).unwrap();
} }
#[test]
fn test_circuit_explicit_define() {
let program_string = r#"
circuit One {
x: u8,
}
function main () {
let x: One = One {x: 5};
}
"#;
load_asg(program_string).unwrap();
}