This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
C# code generation generates invalid code when accessing UDT items named Data. #37
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When a UDT has a named item whose name is Data, accessing that item causes C# code generation to display a warning:
Microsoft (R) Build Engine version 16.3.0-preview-19377-01+dd8019d9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 23.26 ms for C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj.
You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
obj\qsharp\src\Operations.g.cs(27,31): warning CS0108: 'Foo.Data' hides inherited member 'QTuple<IQArray<long>>.Data'. Use the new keyword if hiding was intended. [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
runtime-bug -> C:\Users\<redacted>\tmp\runtime-bug\bin\Debug\netcoreapp2.1\runtime-bug.dll
If the UDT contains named items other than Data as well, then the code generation step fails entirely:
Microsoft (R) Build Engine version 16.3.0-preview-19377-01+dd8019d9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 24.7 ms for C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj.
You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
obj\qsharp\src\Operations.g.cs(27,31): warning CS0108: 'Foo.Data' hides inherited member 'QTuple<(IQArray<long>, string)>.Data'. Use the new keyword if hiding was intended. [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(27,44): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item1' and no accessible extension method 'Item1' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(28,45): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item2' and no accessible extension method 'Item2' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(29,45): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item1' and no accessible extension method 'Item1' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(30,37): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item2' and no accessible extension method 'Item2' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(34,26): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item1' and no accessible extension method 'Item1' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
obj\qsharp\src\Operations.g.cs(35,26): error CS1061: 'IQArray<long>' does not contain a
definition for 'Item2' and no accessible extension method 'Item2' accepting a first argument of type 'IQArray<long>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\<redacted>\tmp\runtime-bug\runtime-bug.csproj]
In either case, when calling from IQ#, the kernel dies with no error message printed to the notebook or the console.
To Reproduce
open Microsoft.Quantum.Arrays;
newtype Foo = (Data: Int[]);
function Example() : Foo[] {
return Mapped(Foo, [[1, 2], [3, 4, 5], new Int[0], [16]]);
}
function Boom() : Int {
let foos = Example();
return foos[0]::Data[0];
}Renaming Data → NotData, the example works as expected.
See https://gist.github.com/cgranade/ee913899e0b40e8ee8cd43b82632a454 for IQ# version.
System information
-
OS: Windows 10
-
.NET Core Version: 3.0.100-preview8-013656
-
IQ# Version: 0.8.1907.1701
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working