Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion images/iqsharp-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ENV PATH=$PATH:${HOME}/dotnet:${HOME}/.dotnet/tools \
# Install IQ# and the project templates, using the NuGet packages from the
# build context.
ARG IQSHARP_VERSION
RUN dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.12.20082515-beta" && \
RUN dotnet new -i "Microsoft.Quantum.ProjectTemplates::0.12.20101601-beta" && \
dotnet tool install \
--global \
Microsoft.Quantum.IQSharp \
Expand Down
2 changes: 1 addition & 1 deletion src/AzureClient/AzureClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.12.20101601-beta" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.21" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="System.Reactive" Version="4.3.2" />
Expand Down
22 changes: 11 additions & 11 deletions src/Core/Compiler/CompilerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public IEnumerable<QsNamespaceElement> IdentifyElements(string source)
return loader.VerifiedCompilation.Tokenization.Values
.SelectMany(tokens => tokens.SelectMany(fragments => fragments))
.Where(fragment => fragment.Kind != null && fragment.Kind.IsOpenDirective)
.Select(fragment => ((QsFragmentKind.OpenDirective)fragment.Kind))
.Select(fragment => ((QsFragmentKind.OpenDirective)fragment.Kind!))
.Where(openDirective => !string.IsNullOrEmpty(openDirective.Item1.Symbol?.AsDeclarationName(null)))
.ToDictionary(
openDirective => openDirective.Item1.Symbol.AsDeclarationName(null),
Expand All @@ -126,9 +126,9 @@ public IEnumerable<QsNamespaceElement> IdentifyElements(string source)
/// if the keys of the given references differ from the currently loaded ones.
/// Returns an enumerable of all namespaces, including the content from both source files and references.
/// </summary>
private QsCompilation UpdateCompilation(
private QsCompilation? UpdateCompilation(
ImmutableDictionary<Uri, string> sources,
QsReferences? references = null,
QsReferences references,
QSharpLogger? logger = null,
bool compileAsExecutable = false,
string? executionTarget = null,
Expand Down Expand Up @@ -186,15 +186,15 @@ string WrapInNamespace(Snippet s) =>
var sources = snippets.ToImmutableDictionary(s => s.Uri, WrapInNamespace);

// Ignore some warnings about already-open namespaces and aliases when compiling snippets.
var errorCodesToIgnore = new List<QsCompiler.Diagnostics.ErrorCode>()
var warningCodesToIgnore = new List<QsCompiler.Diagnostics.WarningCode>()
{
QsCompiler.Diagnostics.ErrorCode.TypeRedefinition,
QsCompiler.Diagnostics.ErrorCode.TypeConstructorOverlapWithCallable,
QsCompiler.Diagnostics.WarningCode.NamespaceAleadyOpen,
QsCompiler.Diagnostics.WarningCode.NamespaceAliasIsAlreadyDefined,
};

errorCodesToIgnore.ForEach(code => logger.ErrorCodesToIgnore.Add(code));
warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Add(code));
var assembly = BuildAssembly(sources, metadatas, logger, dllName, compileAsExecutable: false, executionTarget, runtimeCapabilities);
errorCodesToIgnore.ForEach(code => logger.ErrorCodesToIgnore.Remove(code));
warningCodesToIgnore.ForEach(code => logger.WarningCodesToIgnore.Remove(code));

return assembly;
}
Expand All @@ -218,11 +218,11 @@ string WrapInNamespace(Snippet s) =>
logger.LogDebug($"Compiling the following Q# files: {string.Join(",", sources.Keys.Select(f => f.LocalPath))}");

// Ignore any @EntryPoint() attributes found in libraries.
logger.ErrorCodesToIgnore.Add(QsCompiler.Diagnostics.ErrorCode.EntryPointInLibrary);
logger.WarningCodesToIgnore.Add(QsCompiler.Diagnostics.WarningCode.EntryPointInLibrary);
var qsCompilation = this.UpdateCompilation(sources, metadata.QsMetadatas, logger, compileAsExecutable, executionTarget, runtimeCapabilities);
logger.ErrorCodesToIgnore.Remove(QsCompiler.Diagnostics.ErrorCode.EntryPointInLibrary);
logger.WarningCodesToIgnore.Remove(QsCompiler.Diagnostics.WarningCode.EntryPointInLibrary);

if (logger.HasErrors) return null;
if (logger.HasErrors || qsCompilation == null) return null;

try
{
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.20101601-beta" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.12.20101601-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20101601-beta" />
<PackageReference Include="NuGet.Resolver" Version="5.1.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Loggers/QsharpLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;

using Microsoft.Extensions.Logging;

using Microsoft.Quantum.QsCompiler.CompilationBuilder;
using LSP = Microsoft.VisualStudio.LanguageServer.Protocol;


Expand All @@ -23,6 +23,7 @@ public class QSharpLogger : QsCompiler.Diagnostics.LogTracker
public List<LSP.Diagnostic> Logs { get; }

public List<QsCompiler.Diagnostics.ErrorCode> ErrorCodesToIgnore { get; } = new List<QsCompiler.Diagnostics.ErrorCode>();
public List<QsCompiler.Diagnostics.WarningCode> WarningCodesToIgnore { get; } = new List<QsCompiler.Diagnostics.WarningCode>();

public QSharpLogger(ILogger logger, int lineNrOffset = 0) :
base(lineNrOffset : lineNrOffset)
Expand Down Expand Up @@ -75,7 +76,8 @@ public static LogLevel MapLevel(LSP.DiagnosticSeverity original)

protected override void Print(LSP.Diagnostic m)
{
if (ErrorCodesToIgnore.Any(code => m.Code == QsCompiler.CompilationBuilder.Errors.Code(code))) return;
if (m.IsError() && ErrorCodesToIgnore.Any(code => m.Code == QsCompiler.CompilationBuilder.Errors.Code(code))) return;
if (m.IsWarning() && WarningCodesToIgnore.Any(code => m.Code == QsCompiler.CompilationBuilder.Warnings.Code(code))) return;

Logger?.Log(MapLevel(m.Severity), $"{m.Code}: {m.Message}");
Logs.Add(m);
Expand Down
2 changes: 1 addition & 1 deletion src/ExecutionPathTracer/ExecutionPathTracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20101601-beta" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Chemistry/Mock.Chemistry.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20082515-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20101601-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20101601-beta" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Standard/Mock.Standard.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20082515-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20101601-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.12.20101601-beta" />
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions src/Tests/AzureClientEntryPointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Quantum.IQSharp;
using Microsoft.Quantum.IQSharp.AzureClient;
using Microsoft.Quantum.IQSharp.Common;
using Microsoft.Quantum.Runtime;
using Microsoft.Quantum.Simulation.Common;
using Microsoft.Quantum.Simulation.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests.IQSharp
Expand Down
12 changes: 12 additions & 0 deletions src/Tests/IQsharpEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ public async Task OpenAliasedNamespaces()
await AssertSimulate(engine, "DependsOnAliasedNamespace", "Hello from DependsOnAliasedNamespace");
}

[TestMethod]
public async Task CompileApplyWithin()
{
var engine = Init();

// Compile:
await AssertCompile(engine, SNIPPETS.ApplyWithinBlock, "ApplyWithinBlock");

// Run:
await AssertSimulate(engine, "ApplyWithinBlock", "Within", "Apply", "Within");
}

[TestMethod]
public async Task Estimate()
{
Expand Down
22 changes: 22 additions & 0 deletions src/Tests/SNIPPETS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ operation DependsOnAliasedNamespace() : Unit
}
";

public static string ApplyWithinBlock =
@"
/// # Summary
/// Checks that within/apply block is properly compiled.
/// See https://github.com/microsoft/iqsharp/issues/266.
@EntryPoint()
operation ApplyWithinBlock() : Unit
{
using (q = Qubit())
{
within {
H(q);
Message(""Within"");
}
apply {
X(q);
Message(""Apply"");
}
}
}
";

public static string DependsOnWorkspace =
@"
/// # Summary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20082515-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20101601-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20082515-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20101601-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20082515-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.20101601-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand All @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.12.20082515-beta" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.12.20101601-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
32 changes: 16 additions & 16 deletions src/Tool/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
},
"AllowedHosts": "*",
"DefaultPackageVersions": [
"Microsoft.Quantum.Compiler::0.12.20082515-beta",
"Microsoft.Quantum.Compiler::0.12.20101601-beta",

"Microsoft.Quantum.CsharpGeneration::0.12.20082515-beta",
"Microsoft.Quantum.Development.Kit::0.12.20082515-beta",
"Microsoft.Quantum.Simulators::0.12.20082515-beta",
"Microsoft.Quantum.Xunit::0.12.20082515-beta",
"Microsoft.Quantum.CsharpGeneration::0.12.20101601-beta",
"Microsoft.Quantum.Development.Kit::0.12.20101601-beta",
"Microsoft.Quantum.Simulators::0.12.20101601-beta",
"Microsoft.Quantum.Xunit::0.12.20101601-beta",

"Microsoft.Quantum.Standard::0.12.20082515-beta",
"Microsoft.Quantum.Standard.Visualization::0.12.20082515-beta",
"Microsoft.Quantum.Chemistry::0.12.20082515-beta",
"Microsoft.Quantum.Chemistry.Jupyter::0.12.20082515-beta",
"Microsoft.Quantum.MachineLearning::0.12.20082515-beta",
"Microsoft.Quantum.Numerics::0.12.20082515-beta",
"Microsoft.Quantum.Standard::0.12.20101601-beta",
"Microsoft.Quantum.Standard.Visualization::0.12.20101601-beta",
"Microsoft.Quantum.Chemistry::0.12.20101601-beta",
"Microsoft.Quantum.Chemistry.Jupyter::0.12.20101601-beta",
"Microsoft.Quantum.MachineLearning::0.12.20101601-beta",
"Microsoft.Quantum.Numerics::0.12.20101601-beta",

"Microsoft.Quantum.Katas::0.12.20082515-beta",
"Microsoft.Quantum.Katas::0.12.20101601-beta",

"Microsoft.Quantum.Research::0.12.20082515-beta",
"Microsoft.Quantum.Research::0.12.20101601-beta",

"Microsoft.Quantum.Providers.IonQ::0.12.20082515-beta",
"Microsoft.Quantum.Providers.Honeywell::0.12.20082515-beta",
"Microsoft.Quantum.Providers.QCI::0.12.20082515-beta"
"Microsoft.Quantum.Providers.IonQ::0.12.20101601-beta",
"Microsoft.Quantum.Providers.Honeywell::0.12.20101601-beta",
"Microsoft.Quantum.Providers.QCI::0.12.20101601-beta"
]
}