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

Syntax Error when compiling nested If statements using flow optimization #1527

Open
sebw42 opened this issue Nov 6, 2024 · 1 comment
Open

Comments

@sebw42
Copy link

sebw42 commented Nov 6, 2024

Hi, I noticed that when using the flow optimization, nested if statements can cause the compiler to throw a syntax error.
Here is an example program that triggers the error:

a = 1
if True:
    if True:
        a = 2
    if True:
        a = 3
else:
    a = 4

Compiling this with ./compile.py -l program results in the following output:

Default bit length for compilation: 64
Default security parameter for compilation: 40
Compiling file Programs/Source/program.mpc
Traceback (most recent call last):
  File "MP-SPDZ/./compile.py", line 41, in <module>
    main(compiler)
  File "MP-SPDZ/./compile.py", line 36, in main
    compilation(compiler)
  File "MP-SPDZ/./compile.py", line 19, in compilation
    prog = compiler.compile_file()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "MP-SPDZ/Compiler/compilerLib.py", line 479, in compile_file
    exec(compile(infile.read(), infile.name, "exec"), self.VARS)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/tmph9_6ft_w", line 10
    else:
    ^^^^
SyntaxError: invalid syntax

Compiling without -l or removing one of the inner if statements fixes the problem.
Thanks for looking into this!

@mkskeller
Copy link
Member

mkskeller commented Nov 11, 2024

Thank you for raising this. You should find that 94b8c33 fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants