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

Commit 851a8e3

Browse files
authored
Fixing a couple of issues (#447)
1 parent bb083c9 commit 851a8e3

File tree

24 files changed

+168
-74
lines changed

24 files changed

+168
-74
lines changed

QsCompiler.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Optimizations", "src\QsComp
4444
EndProject
4545
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B4A9484D-31FC-4A27-9E26-4C8DE3E02D77}"
4646
EndProject
47+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library2", "src\QsCompiler\TestTargets\Libraries\Library2\Library2.csproj", "{E7E019AB-42F8-48AB-B80C-D33351F2C96A}"
48+
EndProject
4749
Global
4850
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4951
Debug|Any CPU = Debug|Any CPU
@@ -258,6 +260,18 @@ Global
258260
{31085984-3DA6-43C7-B0AA-CE62DC60BB56}.Release|x64.Build.0 = Release|Any CPU
259261
{31085984-3DA6-43C7-B0AA-CE62DC60BB56}.Release|x86.ActiveCfg = Release|Any CPU
260262
{31085984-3DA6-43C7-B0AA-CE62DC60BB56}.Release|x86.Build.0 = Release|Any CPU
263+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
264+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|Any CPU.Build.0 = Debug|Any CPU
265+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|x64.ActiveCfg = Debug|Any CPU
266+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|x64.Build.0 = Debug|Any CPU
267+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|x86.ActiveCfg = Debug|Any CPU
268+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Debug|x86.Build.0 = Debug|Any CPU
269+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|Any CPU.ActiveCfg = Release|Any CPU
270+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|Any CPU.Build.0 = Release|Any CPU
271+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|x64.ActiveCfg = Release|Any CPU
272+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|x64.Build.0 = Release|Any CPU
273+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|x86.ActiveCfg = Release|Any CPU
274+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A}.Release|x86.Build.0 = Release|Any CPU
261275
EndGlobalSection
262276
GlobalSection(SolutionProperties) = preSolution
263277
HideSolutionNode = FALSE
@@ -271,6 +285,7 @@ Global
271285
{2E331781-F7ED-4EF1-8451-896636C6D93A} = {76BA96DA-DC1E-4315-A3ED-5F0700A79812}
272286
{D2E36476-A65F-4310-9C4C-B721BCC47B00} = {6077A717-50BF-4F87-B439-CA549AF6A4AE}
273287
{DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F} = {D2E36476-A65F-4310-9C4C-B721BCC47B00}
288+
{E7E019AB-42F8-48AB-B80C-D33351F2C96A} = {D2E36476-A65F-4310-9C4C-B721BCC47B00}
274289
EndGlobalSection
275290
GlobalSection(ExtensibilityGlobals) = postSolution
276291
SolutionGuid = {B921C36B-4574-4025-8FE3-E5BD2D3D2B81}

build/build.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ if ($Env:ENABLE_VSIX -ne "false") {
107107
Build-VS
108108
} else {
109109
Write-Host "##vso[task.logissue type=warning;]VSIX building skipped due to ENABLE_VSIX variable."
110-
return
111110
}
112111

113112
if (-not $all_ok) {

build/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trigger:
44

55
variables:
66
Build.Major: 0
7-
Build.Minor: 10
7+
Build.Minor: 11
88
Assembly.Version: $(Build.BuildNumber)
99
Assembly.Constants: ''
1010
Drops.Dir: $(Build.ArtifactStagingDirectory)/drops

examples/CompilerExtensions/CustomExtension/CustomExtension.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.10.2003.1821-beta" />
8+
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.11.2006.411-beta" />
99
</ItemGroup>
1010

1111
</Project>

examples/CompilerExtensions/Demo/Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.Quantum.Sdk/0.10.2003.1821-beta">
1+
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.411-beta">
22

33
<PropertyGroup>
44
<QscVerbosity>Detailed</QscVerbosity>

examples/CompilerExtensions/Demo/Driver.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/CompilerExtensions/Demo/Program.qs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
return (n, n+1);
55
}
66

7+
@EntryPoint()
78
operation SampleProgram () : Int {
89
let (a, b) = GetPair(5);
910
return a + b;

src/QsCompiler/CompilationManager/CompilationUnit.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ static QsDeclarationAttribute Renamed(QsQualifiedName originalName, Tuple<int, i
115115
var rename = new RenameReferences(renaming);
116116
var types = headers.Types
117117
.Select(type =>
118-
renaming.ContainsKey(type.QualifiedName) && type.Location.IsValue // TODO: we should instead fully support auto-generated attributes
118+
renaming.TryGetValue(type.QualifiedName, out var newName) && !type.QualifiedName.Equals(newName) && type.Location.IsValue // TODO: we should instead fully support auto-generated attributes
119119
? type.AddAttribute(Renamed(type.QualifiedName, type.Location.Item.Offset))
120120
: type)
121121
.Select(rename.OnTypeDeclarationHeader);
122122
var callables = headers.Callables
123123
.Select(callable =>
124-
renaming.ContainsKey(callable.QualifiedName) && callable.Location.IsValue // TODO: we should instead fully support auto-generated attributes
124+
renaming.TryGetValue(callable.QualifiedName, out var newName) && !callable.QualifiedName.Equals(newName) && callable.Location.IsValue // TODO: we should instead fully support auto-generated attributes
125125
? callable.AddAttribute(Renamed(callable.QualifiedName, callable.Location.Item.Offset))
126126
: callable)
127127
.Select(rename.OnCallableDeclarationHeader);
@@ -186,13 +186,13 @@ public References(ImmutableDictionary<NonNullable<string>, Headers> refs, bool l
186186
}
187187

188188
if (onError == null) return;
189-
var conflictingCallables = refs.Values
189+
var conflictingCallables = this.Declarations.Values
190190
.SelectMany(r => r.Callables)
191191
.Where(c => Namespace.IsDeclarationAccessible(false, c.Modifiers.Access))
192192
.GroupBy(c => c.QualifiedName)
193193
.Where(g => g.Count() != 1)
194194
.Select(g => (g.Key, String.Join(", ", g.Select(c => c.SourceFile.Value))));
195-
var conflictingTypes = refs.Values
195+
var conflictingTypes = this.Declarations.Values
196196
.SelectMany(r => r.Types)
197197
.Where(t => Namespace.IsDeclarationAccessible(false, t.Modifiers.Access))
198198
.GroupBy(t => t.QualifiedName)

src/QsCompiler/Compiler/ExternalRewriteSteps.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,24 @@ Uri WithFullPath(string file)
243243
onDiagnostic?.Invoke(LoadError(ErrorCode.FileIsNotAnAssembly, target.LocalPath));
244244
onException?.Invoke(ex);
245245
}
246+
catch (ReflectionTypeLoadException ex)
247+
{
248+
var sb = new System.Text.StringBuilder();
249+
foreach (var exSub in ex.LoaderExceptions)
250+
{
251+
var msg = exSub.ToString();
252+
if (msg != null) sb.AppendLine(msg);
253+
if (exSub is FileNotFoundException exFileNotFound && !string.IsNullOrEmpty(exFileNotFound.FusionLog))
254+
{
255+
sb.AppendLine("Fusion Log:");
256+
sb.AppendLine(exFileNotFound.FusionLog);
257+
sb.AppendLine();
258+
}
259+
}
260+
261+
onDiagnostic?.Invoke(LoadError(ErrorCode.TypeLoadExceptionInCompilerPlugin, target.LocalPath));
262+
onException?.Invoke(new TypeLoadException(sb.ToString(), ex.InnerException));
263+
}
246264
catch (Exception ex)
247265
{
248266
onDiagnostic?.Invoke(LoadError(ErrorCode.CouldNotLoadCompilerPlugin, target.LocalPath));

src/QsCompiler/Core/Dependencies.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Microsoft.Quantum.QsCompiler
55

66
open System.Collections.Immutable
77
open Microsoft.Quantum.QsCompiler.DataTypes
8+
open Microsoft.Quantum.QsCompiler.ReservedKeywords
89
open Microsoft.Quantum.QsCompiler.SyntaxTree
910

1011

@@ -57,7 +58,12 @@ type BuiltIn = {
5758

5859
/// Returns true if the given attribute defines an alternative name that may be used when loading a type or callable for testing purposes.
5960
static member internal DefinesNameForTesting (att : QsDeclarationAttribute) = att.TypeId |> function
60-
| Value tId -> tId.Namespace.Value = BuiltIn.EnableTestingViaName.FullName.Namespace.Value && tId.Name.Value = BuiltIn.Test.FullName.Name.Value
61+
| Value tId -> tId.Namespace.Value = BuiltIn.EnableTestingViaName.FullName.Namespace.Value && tId.Name.Value = BuiltIn.EnableTestingViaName.FullName.Name.Value
62+
| Null -> false
63+
64+
/// Returns true if the given attribute indicates that the type or callable has been loaded via an alternative name for testing purposes.
65+
static member internal DefinesLoadedViaTestNameInsteadOf (att : QsDeclarationAttribute) = att.TypeId |> function
66+
| Value tId -> tId.Namespace.Value = GeneratedAttributes.Namespace && tId.Name.Value = GeneratedAttributes.LoadedViaTestNameInsteadOf
6167
| Null -> false
6268

6369

0 commit comments

Comments
 (0)