Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Lambda functions and operations cannot be used from IQ#. #606

Description

Describe the bug
New lambda functions and operations (e.g.: (x) -> x) cannot currently be compiled using IQ#.

To Reproduce

Steps to reproduce the behavior:

  1. From a Python + Q# notebook, run import qsharp, and then run the cell:
    %%qsharp
    function Foo() : Unit {
        let f = x -> x;
        let y = f(12);
    }
  2. Observe error:
    : error IQS002: Unexpected error compiling assembly: Can't generate code for un-lifted lambda..
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    ~\AppData\Local\Temp/ipykernel_35408/4074425879.py in <module>
    ----> 1 get_ipython().run_cell_magic('qsharp', '', 'function Foo() : Unit {\n    let f = x -> x;\n    
    let y = f(12);\n}\n')
    
    ~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
       2417             with self.builtin_trap:
       2418                 args = (magic_arg_s, cell)
    -> 2419                 result = fn(*args, **kwargs)
       2420             return result
       2421 
    
    ~\Anaconda3\lib\site-packages\qsharp\ipython_magic.py in qsharp(magic_args, cell, local_ns)
         26             local_ns[callables._name] = callables
         27         else:
    ---> 28             for qs_callable in callables:
         29                 local_ns[qs_callable._name] = qs_callable
         30 
    
    TypeError: 'NoneType' object is not iterable
    

Expected behavior
The above snippet should either compile correctly or fail with a clear and actionable error message.

Screenshots
image

System information

In []: qsharp.component_versions()
Out[]: {'iqsharp': LooseVersion ('0.23.195983'),
 'Jupyter Core': LooseVersion ('1.5.0.0'),
 '.NET Runtime': LooseVersion ('.NETCoreApp,Version=v3.1'),
 'qsharp': LooseVersion ('0.23.195983')}

Additional context

SamarSha has shared that the root cause may be the default value of the CompilationLoader.Configuration.LiftLambdaFunctions property as implicitly used at:

var loadOptions = new CompilationLoader.Configuration

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions