Skip to content

Commit 29ea1ac

Browse files
committed
checking forbidden names when generating c files and error in --> checking in anonymous components with multiple outputs
1 parent 77b36a9 commit 29ea1ac

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

circom/src/input_user.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,19 @@ const JSON: &'static str = "json";
4747

4848
impl Input {
4949
pub fn new() -> Result<Input, ()> {
50+
use ansi_term::Colour;
5051
use input_processing::SimplificationStyle;
5152
let matches = input_processing::view();
5253
let input = input_processing::get_input(&matches)?;
53-
let file_name = input.file_stem().unwrap().to_str().unwrap().to_string();
54+
let mut file_name = input.file_stem().unwrap().to_str().unwrap().to_string();
5455
let output_path = input_processing::get_output_path(&matches)?;
56+
57+
let c_flag = input_processing::get_c(&matches);
58+
59+
if c_flag && (file_name == "main" || file_name == "fr" || file_name == "calcwit"){
60+
println!("{}", Colour::Yellow.paint(format!("The name {} is reserved in Circom when using de --c flag. The files generated for your circuit will use the name {}_c instead of {}.", file_name, file_name, file_name)));
61+
file_name = format!("{}_c", file_name)
62+
};
5563
let output_c_path = Input::build_folder(&output_path, &file_name, CPP);
5664
let output_js_path = Input::build_folder(&output_path, &file_name, JS);
5765
let o_style = input_processing::get_simplification_style(&matches)?;
@@ -76,7 +84,7 @@ impl Input {
7684
),
7785
wat_flag:input_processing::get_wat(&matches),
7886
wasm_flag: input_processing::get_wasm(&matches),
79-
c_flag: input_processing::get_c(&matches),
87+
c_flag: c_flag,
8088
r1cs_flag: input_processing::get_r1cs(&matches),
8189
sym_flag: input_processing::get_sym(&matches),
8290
main_inputs_flag: input_processing::get_main_inputs_log(&matches),

parser/src/syntax_sugar_remover.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn check_anonymous_components_statement(
5555
"An anonymous component cannot be used in the left side of an assignment".to_string())
5656
)
5757
} else{
58-
if rhe.contains_anonymous_comp() && *op != AssignOp::AssignSignal{
58+
if rhe.contains_anonymous_comp() && *op == AssignOp::AssignSignal{
5959
let error = format!("Anonymous components only admit the use of the operator <==");
6060
Result::Err(anonymous_general_error(meta.clone(),error))
6161
} else{

0 commit comments

Comments
 (0)