File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1- from kirin import ir , types , lowering
1+ from kirin import ir , types , interp , lowering
22from kirin .decl import info , statement
33from kirin .dialects import ilist
44
@@ -41,3 +41,18 @@ class MeasurementId(ir.Statement):
4141class Reset (ir .Statement ):
4242 traits = frozenset ({lowering .FromPythonCall ()})
4343 qubits : ir .SSAValue = info .argument (ilist .IListType [QubitType , types .Any ])
44+
45+
46+ # TODO: investigate why this is needed to get type inference to be correct.
47+ @dialect .register (key = "typeinfer" )
48+ class __TypeInfer (interp .MethodTable ):
49+ @interp .impl (Measure )
50+ def measure_list (self , _interp , frame : interp .AbstractFrame , stmt : Measure ):
51+ qubit_type = frame .get (stmt .qubits )
52+
53+ if isinstance (qubit_type , types .Generic ):
54+ len_type = qubit_type .vars [1 ]
55+ else :
56+ len_type = types .Any
57+
58+ return (ilist .IListType [MeasurementResultType , len_type ],)
You can’t perform that action at this time.
0 commit comments