Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Compilation Error in Child Program When Referencing Parent Program with Struct #27956

Closed
snowtigersoft opened this issue May 18, 2024 · 0 comments · Fixed by #27962
Closed
Labels
bug Something isn't working

Comments

@snowtigersoft
Copy link

🐛 Bug Report

When attempting to compile two Leo programs, I encountered an issue. Here are the details:

  1. The parent.leo program defines a TestStruct structure and includes one asynchronous transition function. This program compiles successfully on its own.
  2. The child.leo program import parent.leo.
  3. The expectation is that both programs compile successfully, but an error occurs during the compilation of child.leo.

Steps to Reproduce

  1. Create the parent.leo file and add the following code:

    // The 'parent' program.
    program parent.aleo {
        struct TestStruct {
            data0: u128,
            data1: u128
        }
    
        async transition init() -> Future {
            let test_struct: TestStruct = TestStruct {
                data0: 0u128,
                data1: 1u128
            };
            return finalize_init(test_struct);
        }
    
        async function finalize_init(public test_struct: TestStruct) {
            assert_eq(0u32, 0u32);
        }
    }
    
  2. Create the child.leo file and add the following code:

    // The 'child' program.
    import parent.aleo;
    
    program child.aleo {
        transition main() -> u32 {
            return 1u32;
        }
    }
    
  3. Attempt to compile both programs.

Code snippet to reproduce

Please see the code snippets provided above.

Stack trace & error message

The following error occurs during the compilation of child.leo:

Leo ✅ Compiled 'parent.aleo' into Aleo instructions
Error [ETYC0372017]: The type `TestStruct` is not found in the current scope.
    --> parent/src/main.leo:1:1
     |
   1 | // The 'parent' program.
     | 
     |
     = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`
Error [ETYC0372017]: The type `TestStruct` is not found in the current scope.
    --> parent/src/main.leo:1:1
     |
   1 | // The 'parent' program.
     | 
     |
     = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits`

Expected Behavior

The programs should compile successfully.

Your Environment

  • Leo Version: testnet-beta branch (latest)
  • Rust Version: 1.78.0
  • Computer OS: MacOS

Additional Information

I suspect that the issue might be related to the use of struct in the finalize function within the parent.aleo program. This problem only arises when the child.aleo program tries to reference parent.aleo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants