@@ -29,13 +29,15 @@ def call_function(func: DefineFunOp, args: list[SSAValue]) -> CallOp:
29
29
Given a function in smt dialect and its args, return CallOp(func, args) with type checking
30
30
"""
31
31
func_args = func .body .block .args
32
- assert len (func_args ) == len (args )
32
+ if len (func_args ) != len (args ):
33
+ raise ValueError (f"Arguments of the call to function { func .fun_name } mismatch" )
33
34
for f_arg , arg in zip (func_args , args ):
34
35
if f_arg .type != arg .type :
35
- print (func .fun_name )
36
36
print (func_args )
37
37
print (args )
38
- assert f_arg .type == arg .type
38
+ raise ValueError (
39
+ f"Argument of the call to function { func .fun_name } has different type"
40
+ )
39
41
callOp = CallOp .get (func .results [0 ], args )
40
42
return callOp
41
43
@@ -74,7 +76,8 @@ def call_function_and_assert_result(
74
76
equals to the bv
75
77
"""
76
78
callOp = call_function (func , args )
77
- assert len (callOp .results ) == 1
79
+ if len (callOp .results ) != 1 :
80
+ raise ValueError (f"Incorrect returned value { func .fun_name } " )
78
81
firstOp = FirstOp (callOp .results [0 ])
79
82
assertOps = assert_result (firstOp .res , bv )
80
83
return [callOp , firstOp ] + assertOps
@@ -104,7 +107,8 @@ def get_argument_instances_with_effect(
104
107
"""
105
108
result : list [DeclareConstOp | ConstantOp ] = []
106
109
# ignore last effect arg
107
- assert isinstance (func .body .block .args [- 1 ].type , BoolType )
110
+ if not isinstance (func .body .block .args [- 1 ].type , BoolType ):
111
+ raise ValueError (f"Function { func .fun_name } is not ended with effect" )
108
112
for i , arg in enumerate (func .body .block .args [:- 1 ]):
109
113
argType = arg .type
110
114
if i in int_attr :
@@ -207,7 +211,7 @@ def compress_and_op(lst: list[Operation]) -> tuple[SSAValue, list[Operation]]:
207
211
result and a list of constructed and operations
208
212
"""
209
213
if len (lst ) == 0 :
210
- assert False and "cannot compress lst with size 0 to an AndOp"
214
+ raise ValueError ( "cannot compress lst with size 0 to an AndOp" )
211
215
elif len (lst ) == 1 :
212
216
empty_result : list [Operation ] = []
213
217
return (lst [0 ].results [0 ], empty_result )
0 commit comments