diff --git a/pyqir/pyqir/_simple.py b/pyqir/pyqir/_simple.py index b2d00ef5..ac1e2d97 100644 --- a/pyqir/pyqir/_simple.py +++ b/pyqir/pyqir/_simple.py @@ -32,7 +32,7 @@ def __init__( num_qubits: int, num_results: int, context: Optional[Context] = None, - entrypoint_name: str = "main", + entry_point_name: str = "main", ) -> None: """ Initializes a simple module. @@ -41,7 +41,7 @@ def __init__( :param str num_qubits: The number of statically allocated qubits. :param int num_results: The number of statically allocated results. :param Optional[Context] context: The LLVM context. - :param str entrypoint_name: The name of the entry point function. + :param str entry_point_name: The name of the entry point function. """ if context is None: @@ -60,7 +60,7 @@ def __init__( self._num_results = num_results entry_point = pyqir.entry_point( - self._module, entrypoint_name, num_qubits, num_results + self._module, entry_point_name, num_qubits, num_results ) self._builder.insert_at_end(BasicBlock(context, "entry", entry_point)) diff --git a/pyqir/tests/test_simplemodule.py b/pyqir/tests/test_simplemodule.py index a5e1c864..288a29f6 100644 --- a/pyqir/tests/test_simplemodule.py +++ b/pyqir/tests/test_simplemodule.py @@ -28,3 +28,11 @@ def test_default_attributes_are_set() -> None: assert mod.get_flag("dynamic_result_management") is not None assert str(mod.get_flag("dynamic_result_management")) == "i1 false" + + +def test_entry_point_override_is_applied() -> None: + simple = pyqir.SimpleModule("test", 2, 5, entry_point_name="new_entry") + mod = pyqir.Module.from_bitcode(pyqir.Context(), simple.bitcode()) + + entry = next(filter(is_entry_point, mod.functions)) + assert entry.name == "new_entry"