.net macOS上Quantum开发工具包中的编译器错误

.net macOS上Quantum开发工具包中的编译器错误,.net,quantum-computing,q#,.net,Quantum Computing,Q#,我有一个新Microsoft Quantum开发工具包的简单Q#示例的编译错误: namespace Quantum.Bell { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Set (desired: Result, q1: Qubit) : Unit { let current = M(q1); if (desired !=

我有一个新Microsoft Quantum开发工具包的简单Q#示例的编译错误:

namespace Quantum.Bell
{
    open Microsoft.Quantum.Primitive;
    open Microsoft.Quantum.Canon;

    operation Set (desired: Result, q1: Qubit) : Unit
    {
        let current = M(q1);
        if (desired != current)
        {
            X(q1);
        }
    }

    operation BellTest (count : Int, initial: Result) : (Int, Int)
    {
        mutable numOnes = 0;
        using (qubit = Qubit())
        {
            for (test in 1..count)
            {
                Set (initial, qubit);

                let res = M (qubit);

                // Count the number of ones we saw:
                if (res == One)
                {
                    set numOnes = numOnes + 1;
                }
            }
            Set(Zero, qubit);
        }

        // Return number of times we saw a |0> and number of times we saw a |1>
        return (count-numOnes, numOnes);
    }
}
C#量子模拟器代码看起来像

using System;

using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;

namespace Bell
{
    class Driver
    {
        static void Main(string[] args)
        {
            using (var qsim = new QuantumSimulator())
            {
                // Try initial values
                Result[] initials = new Result[] { Result.Zero, Result.One };
                foreach (Result initial in initials)
                {
                    var res = BellTest.Run(qsim, 1000, initial).Result;
                    var (numZeros, numOnes) = res;
                    System.Console.WriteLine(
                        $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}");
                }
            }

            System.Console.WriteLine("Press any key to continue...");
            System.Console.ReadKey();
        }
    }
}
使用
dotnet运行编译时

ip-192-168-1-103:Bell loretoparisi$ dotnet run
Driver.cs(18,31): error CS0103: The name 'BellTest' does not exist in the current context [/Users/loretoparisi/Documents/Projects/AI/quantum/Bell/Bell.csproj]
Driver.cs(19,26): error CS8130: Cannot infer the type of implicitly-typed deconstruction variable 'numZeros'. [/Users/loretoparisi/Documents/Projects/AI/quantum/Bell/Bell.csproj]
Driver.cs(19,36): error CS8130: Cannot infer the type of implicitly-typed deconstruction variable 'numOnes'. [/Users/loretoparisi/Documents/Projects/AI/quantum/Bell/Bell.csproj]

The build failed. Please fix the build errors and run again.

一个更简单的工作示例是。

存在名称空间不匹配:Q#code中使用的名称空间是
Quantum.Bell
,而C#code中使用的名称空间只是
Bell
——您需要修复文件以使用相同的名称空间,或者使用Quantum.Bell添加
到C代码。

我遇到了相同的问题,请参见以下内容:

修改Driver.cs的第6行

namespace Quantum.Bell


或者您可以使用Quantum.Bell添加
而不是添加
名称空间Quantum.Bell

这就是问题所在谢谢!我认为教程中也有一些错误!我将修复文档中的名称空间不匹配。如果您注意到教程中的任何其他错误,请告诉我们好吗?我们在此跟踪文档中的问题:。谢谢你注意到这一点!