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

Implement short-circuiting for assertions #865

Merged
merged 19 commits into from
May 18, 2021
Merged

Conversation

Schaeff
Copy link
Member

@Schaeff Schaeff commented May 14, 2021

currently

if c then foo() else bar() fi

would always panic if foo() panics (even if c in false)

This is because we inline foo(), and conditionally return its result, but if a panic happened in the statements of foo, it would happen even if this branch isn't executed.

With this change, panics in each branch lead to the whole execution panicking only if the given branch is "executed", ie if cis true.

Both branches are still technically being executed (and paid for in terms of constraints), but the behavior is closer to what would expect.

Todo:

  • minimize constraints: next PR
  • try to reduce what we can before flattening to benefit from boolean propagation: next PR
  • tests nested conditionals
  • fix indentation on display implementation
  • put behind flag?

@Schaeff Schaeff requested a review from dark64 May 17, 2021 13:50
@dark64
Copy link
Member

dark64 commented May 17, 2021

Compile config should be updated in the zokrates_js type definition file as well: https://github.com/Zokrates/ZoKrates/blob/conditional-panics/zokrates_js/index.d.ts#L14

@Schaeff
Copy link
Member Author

Schaeff commented May 17, 2021

Compile config should be updated in the zokrates_js type definition file as well: https://github.com/Zokrates/ZoKrates/blob/conditional-panics/zokrates_js/index.d.ts#L14

changed

Copy link
Member

@dark64 dark64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

2 participants