mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 01:01:53 +03:00
fix define circuit inside circuit function bug
This commit is contained in:
parent
46a75e3aa9
commit
a83795eda3
@ -39,7 +39,9 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
members: Vec<CircuitVariableDefinition>,
|
||||
span: Span,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
let mut program_identifier = new_scope(file_scope.clone(), identifier.to_string());
|
||||
// Circuit definitions are located at the minimum file scope
|
||||
let scopes: Vec<&str> = file_scope.split("_").collect();
|
||||
let mut program_identifier = new_scope(scopes[0].to_string(), identifier.to_string());
|
||||
|
||||
if identifier.is_self() {
|
||||
program_identifier = file_scope.clone();
|
||||
|
@ -154,7 +154,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
if num_variables == 1 && num_values == 1 {
|
||||
// Define a single variable with a single value
|
||||
|
||||
let variable = variables.names[0].clone();
|
||||
let expression = self.enforce_expression(
|
||||
cs,
|
||||
|
@ -0,0 +1,13 @@
|
||||
circuit Foo {
|
||||
a: u32,
|
||||
}
|
||||
|
||||
circuit Bar {
|
||||
static function bar() {
|
||||
let f = Foo { a: 0u32 };
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
let b = Bar::bar();
|
||||
}
|
@ -135,6 +135,7 @@ fn test_member_static_function_undefined() {
|
||||
}
|
||||
|
||||
// Mutability
|
||||
|
||||
#[test]
|
||||
fn test_mutate_function_fail() {
|
||||
let bytes = include_bytes!("mut_function_fail.leo");
|
||||
@ -200,6 +201,7 @@ fn test_mutate_variable_fail() {
|
||||
}
|
||||
|
||||
// Self
|
||||
|
||||
#[test]
|
||||
fn test_self_member_pass() {
|
||||
let bytes = include_bytes!("self_member.leo");
|
||||
@ -233,3 +235,11 @@ fn test_pedersen_mock() {
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_define_circuit_inside_circuit_function() {
|
||||
let bytes = include_bytes!("define_circuit_inside_circuit_function.leo");
|
||||
let program = parse_program(bytes).unwrap();
|
||||
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user