Skip to content

[Panic] qsc_rca: Missing check for Adj when passing callables from python #3855

Description

@amcasey

qsc_rca

Missing check for Adj when passing callables from python:

"""Standalone repro: compiling a Q# callable through the Python callable-object API (`Context.compile(callable, *args)`) panics the compiler.

Panic: source/compiler/qsc_rca/src/core.rs:1507:26: adj specialization should exist
Site:  None:None in `None`

Requires only the `qdk` package. Exits 0 if the panic reproduces.
"""

import sys

from qdk import Context, TargetProfile

SOURCE = '// @harness compile PanicHunt.AdjBodyOnly(PanicHunt.BodyOnly)\nnamespace PanicHunt {\n    operation Main() : Unit {}\n\n    operation BodyOnly() : Unit {}\n\n    operation AdjBodyOnly(op : Unit => Unit is Adj) : Unit {\n        Adjoint op();    }\n}\n'

try:
    ctx = Context(target_profile=TargetProfile.Base)
    ctx.eval(SOURCE)
    ctx.compile(ctx.code.PanicHunt.AdjBodyOnly, ctx.code.PanicHunt.BodyOnly)
except BaseException as error:  # pyo3's PanicException derives from BaseException
    if type(error).__name__ == "PanicException":
        print(f"REPRODUCED: compiler panic: {error}")
        sys.exit(0)
    raise
print("NOT REPRODUCED: no panic")
sys.exit(1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions