AleoNet / snarkVM

A Virtual Machine for Zero-Knowledge Executions
https://snarkvm.org
Apache License 2.0
1.08k stars 1.5k forks source link

[Bug] empty struct causes build to fail with cryptic error message #2058

Open cwkang1998 opened 1 year ago

cwkang1998 commented 1 year ago

šŸ› Bug Report

Per title, when defining an empty struct the program fails with a cryptic error message as such:

Error: Failed to parse string. Parsing Error: VerboseError { errors: [("struct MyEmptyStruct:\n\n\nfunction main:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n", Nom(Tag)), ("\n\nstruct MyEmptyStruct:\n\n\nfunction main:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n", Nom(Alt)), ("\n\nstruct MyEmptyStruct:\n\n\nfunction main:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n", Nom(Many1))] }

Below is the program generated from leo build that fails during snarkvm build. If running directly with snarkvm buildsame error occurs.

program empty_struct_error_message.aleo;

struct MyEmptyStruct:

function main:
    input r0 as u32.public;
    input r1 as u32.private;
    add r0 r1 into r2;
    output r2 as u32.private;

If this was intended, the language server should pick it up and the docs should also have this information available.

Steps to Reproduce

  1. Write a leo and aleo program with an empty struct defined.
  2. Build the program
  3. The error should occur.

A minimal reproduction is available here: https://github.com/cwkang1998/aleo-bug-report-reproduction/tree/main/empty_struct_error_message

Expected Behavior

Either an appropriate error should be shown during compilation and language server, or this behavior should be allowed.

Your Environment

raychu86 commented 5 months ago

@d0cd @evan-schott Is this still a relevant concern?