Skip to content

Commit 9675616

Browse files
Add CAIRO_DEBUG_SIERRA_GEN env var..
1 parent f130d45 commit 9675616

File tree

1 file changed

+9
-6
lines changed
  • crates/cairo-lang-compiler/src

1 file changed

+9
-6
lines changed

crates/cairo-lang-compiler/src/db.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ impl ExternalCodeSizeEstimator for RootDatabase {
3939
// TODO(ilya): Consider adding set costs to dummy functions.
4040
let builder = match RunnableBuilder::new(program, Default::default()) {
4141
Ok(builder) => builder,
42-
Err(err) => {
43-
if err.is_ap_overflow_error() {
44-
// If the compilation failed due to an AP overflow, we don't want to panic as it
45-
// can happen for valid code. In this case, the function is
46-
// probably too large for inline so we can just return the max size.
42+
Err(_) => {
43+
if std::env::var("CAIRO_DEBUG_SIERRA_GEN").is_ok() {
44+
// If we are debugging sierra generation, we want to finish the compilation
45+
// rather than panic.
4746
return Ok(isize::MAX);
4847
}
4948

50-
panic!("Failed to compile program to casm.");
49+
panic!(
50+
"Internal compiler error: Failed to compile program to casm. You can set the \
51+
CAIRO_DEBUG_SIERRA_GEN environment if you want to finish the compilation and \
52+
debug the sierra program."
53+
);
5154
}
5255
};
5356
let casm = builder.casm_program();

0 commit comments

Comments
 (0)