-
Notifications
You must be signed in to change notification settings - Fork 364
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
base: develop
Are you sure you want to change the base?
Conversation
let artifacts = check_with_arena(source, location.clone(), resolver, config, &arena)?; | ||
|
||
match artifacts { | ||
CompilationArtifacts::Lib => unreachable!(), |
There was a problem hiding this comment.
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:
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, |
There was a problem hiding this comment.
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
}
Checks the file up to semantics, not requiring an entry point.