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

Introduce compilation mode #988

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Introduce compilation mode #988

wants to merge 6 commits into from

Conversation

Schaeff
Copy link
Member

@Schaeff Schaeff commented Sep 1, 2021

zokrates check -i foo.zok --mode lib

Checks the file up to semantics, not requiring an entry point.

let artifacts = check_with_arena(source, location.clone(), resolver, config, &arena)?;

match artifacts {
CompilationArtifacts::Lib => unreachable!(),
Copy link
Member

@dark64 dark64 Nov 9, 2021

Choose a reason for hiding this comment

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

This might be reachable when called from zokrates-js because the config is passed by the caller:

https://github.com/Zokrates/ZoKrates/pull/988/files#diff-31d8ede13068a8e0e79ec05ff89244788c8903841d377659d712b5d2057e9ea6R109

If my understanding is correct, one could set the mode to lib and call compile which would throw here with no clear message.

@@ -162,9 +168,25 @@ impl fmt::Display for CompileErrorInner {
}
}

#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum CompileMode {
Bin,
Copy link
Member

@dark64 dark64 Nov 9, 2021

Choose a reason for hiding this comment

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

I think we should use something like this here

#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum CompileMode {
    #[serde(rename = "bin")]
    Bin,
    #[serde(rename = "lib")]
    Lib
}

so it's a bit cleaner in js: mode: "lib" instead of mode: "Lib". It's also possible to put #[serde(rename_all = "lowercase")] before the enum definition.

We should also update typescript type information file:
https://github.com/Zokrates/ZoKrates/blob/add-compiler-mode-flag/zokrates_js/index.d.ts#L12

export type CompileMode = "bin" | "lib";

export interface CompileConfig {
   allow_unconstrained_variables?: boolean,
   isolate_branches?: boolean,
   mode?: CompileMode
}

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