mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-26 11:06:00 +03:00
fix circuit resolution
This commit is contained in:
parent
20a046bbbb
commit
b0de29e275
@ -218,21 +218,17 @@ impl InnerScope {
|
||||
.collect::<Result<Vec<_>, AsgConvertError>>()?,
|
||||
),
|
||||
Circuit(name) if name.name == "Self" => Type::Circuit(
|
||||
self.circuit_self
|
||||
.clone()
|
||||
self.resolve_circuit_self()
|
||||
.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(
|
||||
self.circuit_self
|
||||
.clone()
|
||||
self.resolve_circuit_self()
|
||||
.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))?,
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -120,3 +120,16 @@ fn test_define_circuit_inside_circuit_function() {
|
||||
let program_string = include_str!("define_circuit_inside_circuit_function.leo");
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user