@@ -3339,14 +3339,14 @@ def instrument_auto_finders(self, build_arg_contract_file: str, i: int,
33393339 else :
33403340 added_source_finders = {}
33413341
3342- try :
3343- casting_instrumentations , casting_types = generate_casting_instrumentation ( self . asts , build_arg_contract_file , sdc_pre_finder )
3344- except Exception as e :
3345- instrumentation_logger . warning (
3346- f"Computing casting instrumentation failed for { build_arg_contract_file } : { e } " , exc_info = True )
3347- casting_instrumentations , casting_types = {}, {}
3348-
3349- instr = CertoraBuildGenerator .merge_dicts_instrumentation (instr , casting_instrumentations )
3342+ if self . context . safe_casting_builtin :
3343+ try :
3344+ casting_instrumentations , casting_types = generate_casting_instrumentation ( self . asts , build_arg_contract_file , sdc_pre_finder )
3345+ except Exception as e :
3346+ instrumentation_logger . warning (
3347+ f"Computing casting instrumentation failed for { build_arg_contract_file } : { e } " , exc_info = True )
3348+ casting_instrumentations , casting_types = {}, {}
3349+ instr = CertoraBuildGenerator .merge_dicts_instrumentation (instr , casting_instrumentations )
33503350
33513351 abs_build_arg_contract_file = Util .abs_posix_path (build_arg_contract_file )
33523352 if abs_build_arg_contract_file not in instr :
@@ -3401,12 +3401,13 @@ def instrument_auto_finders(self, build_arg_contract_file: str, i: int,
34013401 read_so_far += amt + 1 + to_skip
34023402 output .write (in_file .read (- 1 ))
34033403
3404- library_name , funcs = casting_types .get (contract_file , ("" , list ()))
3405- if len (funcs ) > 0 :
3406- output .write (bytes (f"\n library { library_name } " + "{\n " , "utf8" ))
3407- for f in funcs :
3408- output .write (bytes (f , "utf8" ))
3409- output .write (bytes ("}\n " , "utf8" ))
3404+ if self .context .safe_casting_builtin :
3405+ library_name , funcs = casting_types .get (contract_file , ("" , list ()))
3406+ if len (funcs ) > 0 :
3407+ output .write (bytes (f"\n library { library_name } " + "{\n " , "utf8" ))
3408+ for f in funcs :
3409+ output .write (bytes (f , "utf8" ))
3410+ output .write (bytes ("}\n " , "utf8" ))
34103411
34113412 new_file = self .to_autofinder_file (build_arg_contract_file )
34123413 self .context .file_to_contract [new_file ] = self .context .file_to_contract [
0 commit comments