Skip to content

Commit 9dbf535

Browse files
committed
Catch curious exception being thrown.
Signed-off-by: Eric Schweitz <[email protected]>
1 parent 09b29a3 commit 9dbf535

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

python/cudaq/kernel/ast_bridge.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -4186,14 +4186,17 @@ def visit_Name(self, node):
41864186
if (isinstance(value, list)):
41874187
errorType = f"{errorType}[{type(value[0]).__name__}]"
41884188

4189-
if issubclass(value, cudaq_runtime.KrausChannel):
4190-
# Here we have a KrausChannel as part of the AST
4191-
# We want to create a hash value from it, and
4192-
# we then want to push the number of parameters and
4193-
# that hash value. This can only be used with apply_noise
4194-
self.pushValue(self.getConstantInt(value.num_parameters))
4195-
self.pushValue(self.getConstantInt(hash(value)))
4196-
return
4189+
try:
4190+
if issubclass(value, cudaq_runtime.KrausChannel):
4191+
# Here we have a KrausChannel as part of the AST
4192+
# We want to create a hash value from it, and
4193+
# we then want to push the number of parameters and
4194+
# that hash value. This can only be used with apply_noise
4195+
self.pushValue(self.getConstantInt(value.num_parameters))
4196+
self.pushValue(self.getConstantInt(hash(value)))
4197+
return
4198+
except TypeError:
4199+
pass
41974200

41984201
self.emitFatalError(
41994202
f"Invalid type for variable ({node.id}) captured from parent scope (only int, bool, float, complex, cudaq.State, and list/np.ndarray[int|bool|float|complex] accepted, type was {errorType}).",

0 commit comments

Comments
 (0)