ProvableHQ / leo

🦁 The Leo Programming Language. A Programming Language for Formally Verified, Zero-Knowledge Applications
https://leo-lang.org/
GNU General Public License v3.0
4.78k stars 661 forks source link

[Bug] Compilation fails on duplicate outputs. #27638

Open d0cd opened 9 months ago

d0cd commented 9 months ago

🐛 Bug Report

Steps to Reproduce

Run this function:

program test_output.aleo {
    transition double_output() -> (u64, u64) {
        return (0u64, 0u64);
    }
}

Find that:

leo run -d --offline --enable-dce-ast-snapshot double_output
       Leo ✅ Compiled 'main.leo' into Aleo instructions
       Leo ✅ Compiled 'token.leo' into Aleo instructions
Cannot add duplicate output statement
Error [ECLI0377008]: Failed to execute the `build` command.
SnarkVM Error: Failed to parse string. Parsing Error: VerboseError { errors: [("\n", Nom(MapRes)), ("\n\n\n\nfunction double_output:\n    output 0u64 as u64.private;\n    output 0u64 as u64.private;\n", Nom(Alt)), ("\n\n\n\nfunction double_output:\n    output 0u64 as u64.private;\n    output 0u64 as u64.private;\n", Nom(Many1))] }

Expected Behavior

Should run successfully.

Your Environment

leo 1.10.0

d0cd commented 9 months ago

Leo should account for duplicate outputs with sufficient compiler warnings.

Or code generation should be modified to handle duplicate outputs. For example, performing identity operations on numeric values and re-initializing composite data types.