Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for unsupported default arguments #658

Closed
CalMacCQ opened this issue Nov 20, 2024 · 0 comments · Fixed by #659 or #655
Closed

Improve error message for unsupported default arguments #658

CalMacCQ opened this issue Nov 20, 2024 · 0 comments · Fixed by #659 or #655
Assignees
Labels
enhancement New feature or request

Comments

@CalMacCQ
Copy link

Consider the following example with a default boolean flag...

@guppy
def qft3(qs: array[qubit, 3], add_swap: bool=True) -> None:
    h(qs[0])
    crz(qs[2], qs[0], pi/2)
    crz(qs[2], qs[0], pi/4)
    h(qs[1])
    crz(qs[2], qs[0], pi/2)
    h(qs[2])

    if add_swap:
        mem_swap(0, 2)

Now if I call this function and only take the qubit array as input (leaving the flag as its True value)

qubits = array(qubit(), qubit(), qubit())
qft3(qubits) # boolean flag not specified

When I compile this function, I get the error message

Error: Not enough arguments (at <In [5]>:18:21)
   | 
16 |             controlled_u(measured[control_index], state)
17 |             
18 |     qft4_inv(measured)
   |                      ^ Missing argument (expected 2, got 1)

Note: Function signature is `(array[qubit, 4], bool) -> None`

Guppy compilation failed due to 1 previous error

I think Ideally it should point out that default function args are an unsupported feature rather than just saying that a function argument is missing.

@ss2165 ss2165 mentioned this issue Nov 12, 2024
9 tasks
@CalMacCQ CalMacCQ added the enhancement New feature or request label Nov 20, 2024
@mark-koch mark-koch self-assigned this Nov 21, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 19, 2024
🤖 I have created a release *beep* *boop*
---


## [0.14.0](v0.13.1...v0.14.0)
(2024-12-19)


### ⚠ BREAKING CHANGES

* Lists in `py(...)` expressions are now turned into Guppy arrays
instead of lists.
* `dirty_qubit` function removed
* measure_return renamed to `project_z`

### Features

* add `maybe_qubit` stdlib function
([#705](#705))
([a49f70e](a49f70e)),
closes [#627](#627)
* add measure_array and discard_array quantum function
([#710](#710))
([3ad49ff](3ad49ff))
* Add method to load pytket circuit without function stub
([#712](#712))
([ee1e3de](ee1e3de))
* Add Option type to standard library
([#696](#696))
([45ea6b7](45ea6b7))
* Allow generic nat args in statically sized ranges
([#706](#706))
([f441bb8](f441bb8)),
closes [#663](#663)
* Array comprehension
([#613](#613))
([fdc0526](fdc0526)),
closes [#614](#614)
[#616](#616)
[#612](#612)
* Implicit coercion of numeric types
([#702](#702))
([df4745b](df4745b)),
closes [#701](#701)
* Load `pytket` circuit as a function definition
([#672](#672))
([b21b7e1](b21b7e1))
* Make arrays iterable
([#632](#632))
([07b9871](07b9871))
* qsystem std functions with updated primitives
([#679](#679))
([b0f041f](b0f041f))
* remove dirty_qubit
([#698](#698))
([78e366b](78e366b))
* Turn py expression lists into arrays
([#697](#697))
([d52a00a](d52a00a))
* Unpacking assignment of iterable types with static size
([#688](#688))
([602e243](602e243))
* update to hugr 0.10 and tket2 0.6
([#725](#725))
([63ea7a7](63ea7a7))


### Bug Fixes

* Accept non-negative int literals and py expressions as nats
([#708](#708))
([a93d4fe](a93d4fe)),
closes [#704](#704)
* Allow borrowing inside comprehensions
([#723](#723))
([02b6ab0](02b6ab0)),
closes [#719](#719)
* Detect unsupported default arguments
([#659](#659))
([94ac7e3](94ac7e3)),
closes [#658](#658)
* docs build command
([#729](#729))
([471b74c](471b74c))
* Ensure `int`s can be treated as booleans
([#709](#709))
([6ef6d60](6ef6d60)),
closes [#681](#681)
* Fix array execution bugs
([#731](#731))
([0f6ceaa](0f6ceaa))
* Fix implicit modules in IPython shells
([#662](#662))
([4ecb5f2](4ecb5f2)),
closes [#661](#661)
* Properly report error for unsupported constants
([#724](#724))
([d0c2da4](d0c2da4)),
closes [#721](#721)
* Properly report errors for unsupported expressions
([#692](#692))
([7f24264](7f24264)),
closes [#691](#691)
* remove use of deprecated Ellipsis
([#699](#699))
([b819a84](b819a84))


### Documentation

* Fix docs build ([#700](#700))
([684f485](684f485)),
closes [#680](#680)
* fix README.md and quickstart.md
([#654](#654))
([abb0221](abb0221))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Seyon Sivarajah <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants