Coder Social home page Coder Social logo

microsoft / qsharp-compiler Goto Github PK

View Code? Open in Web Editor NEW
685.0 44.0 172.0 174.51 MB

Q# compiler, command line tool, and Q# language server

Home Page: https://docs.microsoft.com/quantum

License: MIT License

PowerShell 0.74% C# 51.16% F# 35.07% TypeScript 0.70% Q# 6.98% Dockerfile 0.05% LLVM 5.24% CMake 0.06%
qsharp qdk quantum quantum-development-kit hacktoberfest

qsharp-compiler's Introduction

DEPRECATION NOTICE

This repository is deprecated.

For the Modern QDK repository, please visit Microsoft/qsharp.

You can also try out the Modern QDK in VS Code for Web at vscode.dev/quantum.

For more information about the Modern QDK and Azure Quantum, visit https://aka.ms/AQ/Documentation.

Classic QDK

This repository contains the Q# compiler included in the Quantum Development Kit, as well as the Q# language server included in our Visual Studio extension and our Visual Studio Code extension. For more information related to the language server protocol take a look at this repository. These extensions provide the IDE integration for Q#, and can be found on this repository as well.

The Q# compiler is distributed as a NuGet package, and the CompilationLoader class exposes the different configuration options for building a compilation. The Q# command line compiler is included as a tool in the Microsoft.Quantum.Sdk and provides an extensibility mechanism for compilation steps. See the list of project properties for more information about possible configuration options for Q# projects.

Q# executables can be compiled into an LLVM-based Quantum Intermediate Representation (QIR). More details on that capability and how to use it can be found in this README.

New to Quantum?

See the introduction to quantum computing provided with the Quantum Development Kit.

Installing the Quantum Development Kit

If you're looking to use Q# to write quantum applications, please see the instructions on how to get started with using the Quantum Development Kit including the Q# compiler, language server, and development environment extensions.

Please see the installation guide for further information on how to get started using the Quantum Development Kit to develop quantum applications. You may also visit our Quantum repository, which offers a wide variety of samples on how to write quantum based programs.

Building from Source

Before you can build the source code on this repository and start contributing to the Q# compiler and extensions you need to run the PowerShell script bootstrap.ps1 to set up your environment. We refer to the PowerShell GitHub repository for instructions on how to install PowerShell. The script in particular generates the files that are needed for building based on the templates in this repository.

The Q# compiler and language server in this repository are built using .NET. Building the QsCompiler.sln (dotnet build QsCompiler.sln) builds the Q# compiler and language server. To test your changes to the compiler, open the project file of a Q# project that uses the latest version of the Microsoft.Quantum.Sdk in a text editor. You can confirm the Sdk version that the project is using by looking at the first line in the project file. You may need to edit that line to update to the latest version, and adjust your project as needed. Confirm that the project is building correctly using that version by executing the command

dotnet build MyProject.csproj

If your project builds successfully, edit the project file in the text editor to add the following project property, adjusting the path as needed:

  <PropertyGroup>
    <QscExe>dotnet $(MSBuildThisFileDirectory)src/QsCompiler/CommandLineTool/bin/$(Configuration)/net6.0/qsc.dll</QscExe>
  </PropertyGroup>

To confirm that indeed the locally built compiler version is used, you can edit Run<T> in your local Program.cs file to include the following line:

private static int Run<T>(Func<T, ConsoleLogger, int> compile, T options)
where T : Options
{
    Console.WriteLine("Hi from your locally built compiler!");
    ...

From the root of this repository, build the compiler by executing the two commands

dotnet clean QsCompiler.sln
dotnet build QsCompiler.sln -c Debug

Build the Q# project as usual by invoking the following two commands:

dotnet clean MyProject.csproj
dotnet build MyProject.csproj -c Debug

In the build output you should now see the print statement inserted above. You can also execute the project that has now been built using your local source code version of the compiler by executing the command

dotnet run --project MyProject.csproj -c Debug

If you edit the Microsoft.Quantum.Sdk as part of your changes, you will need to pack it using NuGet 5.8.1. Download it and use it to pack the Sdk by executing the following commands from the root of this repository:

dotnet publish src/QuantumSdk/Tools/Tools.sln -c Debug
dotnet publish src/QsCompiler/CommandLineTool/CommandLineTool.csproj -c Debug
dotnet publish src/QsFmt/App/App.fsproj -c Debug
nuget.exe pack src/QuantumSdk/QuantumSdk.nuspec -Version 1.0.0 -Properties Configuration=Debug

Move the created .nupkg file into your local NuGet folder. You can now use the package to build any Q# project by opening the project file in a text editor, and editing the Sdk version number in the first line to be

<Project Sdk="Microsoft.Quantum.Sdk/1.0.0">

If you are working in Visual Studio, you may need to unload and then reload the project. When you build the project it will now use your locally built version of the Microsoft.Quantum.Sdk.

For instructions on how to build and debug the Visual Studio Code extension take a look at this file. Building and debugging the Visual Studio extension requires Visual Studio 2019. Open the corresponding solution and set the QSharpVsix project as startup project, then launch and debug the extension as usual. The Visual Studio extension is built on the .NET Framework 4.7.2 that comes with Visual Studio 2019. Alternatively you can easily obtain it via the Visual Studio Installer.

We recommend uninstalling any other Q# extensions when working on the extensions in this repository.

Tips for using VSCode

This repository includes both C# and F# code, as well as .csproj and .fsproj projects organizing that code. The recommended extensions for interacting with these language types are the Microsoft C# extension powered by OmniSharp and the Ionide FSharp extension. Several of the projects in each language express dependencies on the other language, which can cause errors resolving namespaces even when the builds succeed without errors. To resolve these errors in C# projects that depend on F# resources, ensure the the MSBuild utilized by Omnisharp comes from an install of Visual Studio or Visual Studio Community edition with support for F# installed. To resolve errors loading .csproj files in the Ionide extension, use the "Change Workspace or Solution" option in the F#: Solution Explorer to select the top level "qsharp-compiler" folder. This will allow Ionide to find only the .fsproj projects instead of trying to load both .csproj and .fsproj listed in the solution files.

Build Status

branch status
main Build Status

Feedback

If you have feedback about the content in this repository, please let us know by filing a new issue! If you have feedback about some other part of the Microsoft Quantum Development Kit, please see the contribution guide for more information.

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Legal and Licensing

Telemetry

By default, sending out telemetry is disabled for all code in this repository, but it can be enabled via compilation flag. Our shipped extensions that are built based on the code in this repository support collecting telemetry. In that case, opt-in or opt-out works via the corresponding setting in Visual Studio and Visual Studio Code, and the telemetry we collect falls under the Microsoft Privacy Statement.

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

For more details, please see CONTRIBUTING.md.

qsharp-compiler's People

Contributors

andreytretyak avatar anjbur avatar anpaz avatar bamarsha avatar bettinaheim avatar bradben avatar cesarzc avatar crazy4pi314 avatar dime10 avatar dmitryvasilevsky avatar filipw avatar israelmiles avatar kevinhartman avatar kuzminrobin avatar microsoftopensource avatar minestarks avatar msoeken avatar raffaeleterribile avatar ricardo-espinoza avatar rsoiffer avatar rstm-sf avatar ryan-moreno avatar scottcarda-ms avatar shalokshalom avatar swernli avatar tcnickolas avatar troelsfr avatar vxfield avatar yjt98765 avatar ziqi-ma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qsharp-compiler's Issues

Code Action for looping over IndexRange

For a for loop over the indices of an array 'arr'
for (i in 0 .. Length(arr)-1) {
// code
}
it would be nice if there was a code action (i.e. the little light-bulbs popping up) that a) makes the edit to
for (i in IndexRange(arr)) {
// code
}
and b) inserts the corresponding open directive for IndexRange if needed.

Describe the solution you'd like
A code action following the same pattern as other code actions should be implemented.
The relevant code is in EditorSupport.cs.

Additional context
Please comment on the issue if you would like to pick it up and would like more details/help.

Incorrect range information for resolved types

Describe the bug
Syntax highlighting, and in particular also renaming shows that the range information for resolved user defined types is incorrect if a user defined type occurs as inner type.

To Reproduce
See e.g. the syntax highlighting for ProtocolMessage in the Superdense coding kata, e.g. in ComposeProtocol.

System information
Irrelevant, affects the (non-beta) extensions versions 0.6.1905.301 - 0.8.1907.1701.

Indentation in Visual Studio

When adding a new line to a code file, the editor usually inserts a suitable indentation for that line. It would be nice to improve the default behavior for Q# in Visual Studio in that regard.
See the comment(s) below for more details.

Code action suggesting replacement for array item updates

Arrays in Q# are immutable, meaning array items cannot be updated once defined. See Local Variables for more details.

As a result, the following code results in a compilation error:

set arr[i] = 1;

Instead, a Copy-and-Update Expression should be used to create a new array with the modified value:

set arr w/= i <- 1;

Since array item updates are a common thing for users to want to do, it'd be nice to have a code action suggesting the copy-and-update expression corresponding to the array item update specified. This can obviously get fairly complicated, but handling the common/easy cases would go a long way.

Generate Debug Symbols

We need to figure out how to provide proper debug support. In particular, we need to look into generating debug symbols. Right now, the debug support in VS works via relying onto the debug support for the generated C# code. This becomes less and less reliable as we do more complex rewrites (like e.g. generating unique symbol names as we inline code blocks).

Wrong automatically generated Adjoint for within ... apply statement

Describe the bug

Wrong automatically generated Adjoint for within {...} apply {...} statement.

To Reproduce
Compile the following Bug.qs:

namespace Buggy 
{
    operation U() : Unit is Adj {}
    operation V() : Unit is Adj {}

    operation Foo() : Unit is Adj {
        within{ U(); } apply { V(); }
    }
}

Open generated C# file Bug.g.cs, and find implementation of public override Func<QVoid, QVoid> AdjointBody member of public partial class Foo : Adjointable<QVoid>, ICallable on line 120:

        public override Func<QVoid, QVoid> AdjointBody => (__in__) =>
        {
#line hidden
            U.Adjoint.Apply(QVoid.Instance);
#line hidden
            V.Adjoint.Apply(QVoid.Instance);
#line hidden
            U.Adjoint.Adjoint.Apply(QVoid.Instance);
#line hidden
            return QVoid.Instance;
        }

Expected behavior
The snippet of C# code above should be

        public override Func<QVoid, QVoid> AdjointBody => (__in__) =>
        {
#line hidden
            U.Apply(QVoid.Instance);
#line hidden
            V.Adjoint.Apply(QVoid.Instance);
#line hidden
            U.Adjoint.Apply(QVoid.Instance);
#line hidden
            return QVoid.Instance;
        }

System information

  • 0.9.1908.2902
  • Windows 10, .Net Core 2.2.401

Support for Code Completion

The Q# integration into Visual Studio via the extension in this repository currently does not provide any code completion suggestions while typing, while the native completion for text documents is available in VS Code. The goal is for the language server to provide completion suggestions informed by the compiler.

Loop Unrolling

We gradually want to incorporate some of the compilation steps and optimizations usually done for classical programming languages (opposed to quantum programming languages) into the Q# compiler. While our focus is naturally on different aspects of a program when compiling and optimizing for execution on a quantum processor, we still need some of the classical infrastructure as well.
In particular, we want some infrastructure for loop unrolling.

Doc Comment Template

It would be nice to have an empty template for a doc comment pop up similar to how it is the case e.g. for C# upon typing ///.

Q# compilation fails if user name contains accented characters

Similarly to #48 compilation also throws errors if your username is "Zoltรกn", most possibly due to an accented character being there. However, I'm not sure; I just know that this fails, while a user account named "Qsharp" works.

Specifically when I try to build the samples I get errors of this sort for all projects:

Severity Description Project
Error The command "dotnet "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\build../tools/qsc/qsc.dll" build --format MsBuild --input "SimpleIsing.qs" --references "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Primitives.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.QsCompilerCommon.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Common.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Core.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Simulators.dll" --output obj\qsharp\src" exited with code -3. SimpleIsingSample

There are a few with error code -2 too:

Severity Description Project
Error The command "dotnet "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\build../tools/qsc/qsc.dll" build --format MsBuild --input "AdiabaticIsing.qs" --references "E:\Projects\Munka\Lombiq\MicrosoftQuantumDevelopmentKitSamples\Samples\src\IsingGenerators\bin\Debug\netcoreapp2.0\IsingGeneratorsSample.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.canon\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Canon.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Primitives.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.QsCompilerCommon.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Common.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Core.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll" "d:\Users\Zoltรกn.nuget\packages\microsoft.quantum.development.kit\0.4.1901.3104\lib\netstandard2.0\Microsoft.Quantum.Simulation.Simulators.dll" --output obj\qsharp\src" exited with code -2. AdiabaticIsingSample

Should this rather go to https://quantum.uservoice.com/forums/906943-setup-and-visual-studio-vs-code-integration?

Bootstrap script is not signed

Describe the bug
When running the bootstrap script, powershell will issue an error saying it cannot be run because the script is not digitally signed
To Reproduce

Clone the repo and try to run the bootstrap script on a machine with execution policy set to remotesigned

Expected behavior
script runs as normal because it is signed

Workaround
Run PS as admin and run "set-executionpolicy unrestricted"

Multifolder workspace support for VS Code

Is your feature request related to a problem? Please describe.
The current version of the VS Code extension is optimized for single-folder workspaces, and in several places assumes that the active workspace contains exactly one folder. This makes it difficult to use the extension in some scenarios, such as that discussed in microsoft/QuantumKatas#150.

Describe the solution you'd like
The lifecycle management for the language server should be extracted from the extension lifecycle for the VS Code extension, making it easier to spin up and spin down copies of the language server process as folders are added to and removed from the active workspace.

TypedExpression.ExtractAll misses a case or two

Describe the bug

The extension method TypedExpression.ExtractAll in DataStructures doesn't seem to handle all cases, in particular, the CopyAndUpdate expression kind.

To Reproduce

Calling ExtractAll on a CopyAndUpdate expression does not apply the extractor function to sub-expressions.

System information

  • Microsoft.Quantum.Compiler version 0.8.1907.1701

Additional context

Glancing at the method implementation, this appears to simply be a missed case in the pattern match. Same issue applies to TypedExpression.Exists. I'm not sure what a "NamedItem" is, but it also has a subexpression and might be another missed match case.

Constant Folding

We gradually want to incorporate some of the compilation steps and optimizations usually done for classical programming languages (opposed to quantum programming languages) into the Q# compiler. While our focus is naturally on different aspects of a program when compiling and optimizing for execution on a quantum processor, we still need some of the classical infrastructure as well.
In particular, we want some infrastructure for constant folding.

Adding an icon (Brand)

Is your feature request related to a problem? Please describe.
The product should represent a specific brand. So for this, Q# should have a nice looking logo. Like everything else.

Describe the solution you'd like
So the logo could have Q# in it, like the C# logo or it could look like the rectangle TS logo. Smth like in here: microsoft/BosqueLanguage#94

Describe alternatives you've considered
Or just the phrase Q#

Allow to easily test compiler modifications

It would be nice if there was as setup to easily test whether the compiler generates code that can be executed on various targets without having to build the compiler package each time.

[MacOS] Visual Studio Code extension does not install .NET Core template

Describe the bug

No Q# template is installed in .NET Core SDK after Visual Studio Code QDK extension is installed under MacOS.

To Reproduce

Steps to reproduce the behavior:

  1. Under macOS Mojave 10.14.6โ€ฆ
  2. Install VS Code 1.36.1
  3. Install .NET Core SDK 2.2
  4. Run VS Code and install extension https://marketplace.visualstudio.com/items?itemName=quantum.quantum-devkit-vscode
  5. Note that installation is very quick
  6. Go to new terminal window and run dotnet new console โ€”list
  7. See that there is only default Console Application for C#/F#/VB and no Q#.
  8. Run dotnet new console -lang Q# --output Bell and see error 'Q#' is not a valid value for -lang (language).

Expected behavior

Expected a Q# project being created using template.

System information

  • macOS Mojave 10.14.
  • .NET Core 2.2.301
  • Visual Studio Code 1.36.1
  • QDK extension: Name: Microsoft Quantum Development Kit for Visual Studio Code
    Id: quantum.quantum-devkit-vscode
    Description: Microsoft Quantum Development Kit for Visual Studio Code provides support for developing quantum algorithms in the Q# programming language.
    Version: 0.8.19071701
    Publisher: Microsoft DevLabs
    VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=quantum.quantum-devkit-vscode

Add switch to short-cut all processing related to tracking edited content

The compiler as it is set up right now is geared towards performing well enough for design time builds during editing. This requires quite a bit of infrastructure and processing during compilation to determine which parts of the compilation need to be recompiled. I meant to add a switch to skip this processing in the case where we just do a command line build, but never got around to it.

Cannot parse smallest possible int64 value

Describe the bug

The smallest possible int64 value -9223372036854775808 cannot be parsed into a Q# Int type.

To Reproduce

A test case to trigger the bug is described in this branch:

https://github.com/msoeken/qsharp-compiler/blob/msoeken/minint-bug/src/QsCompiler/Tests.Compiler/SyntaxTests.fs#L171

Expected behavior

The parser returns an Int value with the smallest integer value.

System information

Reproduced on master, other system information seems to be irrelevant for this bug.

Additional context

Maybe the sign is parsed separate from the int value, since the largest int64 value is 9223372036854775807.

openExternal is not defined for vscode.env in the Visual Studio Code extension

Describe the bug

Visual Studio Code says that openExternal isn't defined:

{
	"resource": "/c:/Users/t-samars/source/repos/qsharp-compiler/src/VSCodeExtension/src/dotnet.ts",
	"owner": "typescript",
	"code": "2339",
	"severity": 8,
	"message": "Property 'openExternal' does not exist on type 'typeof env'.",
	"source": "ts",
	"startLineNumber": 27,
	"startColumn": 32,
	"endLineNumber": 27,
	"endColumn": 44
}

When I open the extension in debug mode it also pops up a message saying there's an error, and I have to click "Debug Anyway" to continue.

To Reproduce

  1. Open the VSCodeExtension folder in Visual Studio Code
  2. Open src/dotnet.ts or try to open the extension in debug mode

Expected behavior

The extension shouldn't have any type errors.

Screenshots

System information

  • Visual Studio Code extension (Git master branch)
  • Windows 10 1809, .NET Core 2.1.701
  • Visual Studio Code 1.36.1

Additional context

The extension still works even with the error. I haven't tested the function so I'm not sure if vscode.env.openExternal really isn't defined at runtime, or if the type checker is wrong.

Allow documenting named items of UDTs

Is your feature request related to a problem? Please describe.
Recently, Q# gained support for UDTs with named items; e.g.: newtype Foo = (A: Int, (B: Bool, C: Qubit)). At the moment, these named items aren't surfaced through to API documentation, such that the names aren't easy to use.

Describe the solution you'd like

/// # Summary
/// ...
///
/// # Named Items
/// ## A
/// ...
/// ## B
/// ...
/// ## C
/// ...
newtype Foo = (A: Int, (B: Bool, C: Qubit))

Compiler-side handling of "try-finally behavior"

Q# currently has two cases that behave like a specific try-finally pattern; qubit scopes and conjugations.
For qubits scopes, returns from within the scope are currently handled by C# on the simulator.
Since we need to be able to handle conjugations entirely on the compiler side, returns from within the apply-block are currently not supported.
We should add a proper translation on the compiler side for both of these cases and similar future cases going forward.

Code action for deprecated unit type

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

-- "()" being used for type and value

Describe the solution you'd like
A clear and concise description of what you want to happen.

-- show code action that replaces the deprecated unit type "()" with "Unit"

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

nob

Describe the bug

Describe what the unexpected behavior or issue is.
Please file a single issue per bug instead of enumerating multiple items.

To Reproduce

Steps to reproduce the behavior:

  1. Open or go to '...'
  2. Type or click on '....'
  3. See error

The more information you can provide, the more likely someone will be successful at reproducing the issue and finding a fix.

Expected behavior

Describe what you expect to happen, versus what actually happened.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • Version of the NuGet package or extension for which the problem occurs
  • Your operating system and .NET Core version
  • For issues with extensions, the version of the IDE for which the problem occurs

Additional context

Add any other context about the problem here.

VS Code extension won't package powershell is not a recognized command

Describe the bug
For packaging the VS Code extension, package.json relies on the existence of the "powershell" command for the prepublish step.

Expected behavior
It would be nice if the packaging worked on systems where powershell is installed but needs to be invoked via "pwsh".

System information
Mac OS

Parsing for Q# attributes

With an end goal of supporting attributes in Q#, the compiler should first be able parse the syntax of attributes and store some information about the identifier and arguments.
For example:

@ExampleAttribute("ExampleArgument")@
operation BitFlip(target : Qubit) : Unit {
    X(target);
}

Docs gen fails if previously generated docs file exist in the same folder

Describe the bug

Running documentation generation twice in a row causes the second execution to fail due to a "key already exists" exception.

To Reproduce

  1. Call the command line compiler specifying --doc "someFolder" (should build fine)
  2. Do the same things again without deleting "someFolder" (fails)

Expected behavior

I think the best thing would be to just silently replace any content that already exists on disk, and maybe log a warning instead. @alan-geller and @anpaz-msft for advice.

System information

irrelevant

Additional context

Mostly, we need to clarify what the correct behavior should be.
The reason docgen reads the files in the folder is to handle the situation where you have a library namespace that spans multiple projects.

Support for conjugation statements

We would like to define on one hand syntactic sugar that allows to more conveniently express what currenently needs to be expressed as call to the combinators With, WithA, WithC, WithAC defined in our libraries. On the other hand, the pattern is relevant for optimization, and I'd thus even represent it in the syntax tree.
More details on this language feature can be found in our specs. We are currently in the process of setting up a repo for those, so the link will follow (my appologies, but I'm happy to elaborate if there are any questions related to this feature in the meantime).

As a side note: we are working on allowing to parametrize over operation characteristics that will e.g. make it possible to express everything covered by With, WithA, WithC and WithAC as a single (family of) operation(s) in the future.

Float data type and IntelliSense on qs code

In the medical imaging domain; my input data is an array of complex numbers. The real and imaginary part of the complex number are float data types.
Unfortunately, using Double (what Q# offers) alters my output and that is not ok. A great suggestion would be to have the Float datatype available.

Another functionality that would be really useful is IntelliSense.
Right now, I first write code, build the project and fix issues.
It would be really great if IntelliSense could analyze Q# code in real time. If this functionality already exists, Iโ€™d be really curious how to activate it.

Additional context
Issue migrated from User Voice.

Provide additional help when unknown identifier caused by missing open statement

Is your feature request related to a problem? Please describe.
When compiling Q# (either as a part of a project, or through IQ#), if an unknown identifier error is caused by forgetting an open statement, it would be great if that could be hinted at in the error message itself. This information is already available through code actions, but that may not be obvious when refactoring a larger project; moreover, code actions aren't available through Jupyter clients.

Describe the solution you'd like
At the moment, error messages look a bit like the following:

/snippet:(3,16): error QS5022: No identifier with that name exists.

An improvement might be something more similar to:

/snippet:(3,16): error QS5022: No identifier with the name MResetZ exists.
    You may be able to fix this error by adding:
    open Microsoft.Quantum.Measurement;

Additional context
This error currently comes up a lot in IQ# especially due to microsoft/iqsharp#15.

On Mac, Code Action only works the first time it is used

I can only use one code action each time I open a file in VS Code. The second time and beyond it does not work.

Steps to reproduce the behavior:

  1. open QuantumKatas/Teleportation in VSCode
  2. Add namespace Foo with a function Bar
  3. Add namespace FooTwo with a function Bar
  4. open both Foo and FooTwo within namespace Quantum.Kata.Teleportation
  5. Call Bar within namespace Quantum.Kata.Teleportation
  6. Close and reopen the file
  7. Select the code action to change it to Foo.Bar (or FooTwo.Bar) [successfully changes it]
  8. Change it back to Bar
  9. Select the code action to change it to Foo.Bar (or FooTwo.Bar)

Expected:
Bar is changed to Foo.Bar

Actual:
Nothing changes

Note: Even if I try to use other code actions (such as deleting a different open statement and using the code action to put it back), none of them work after the first time.

System information

  • macOS Mojave Version 10.14
  • VSCode 1.35.1 and 1.36.1
  • Extension: Microsoft Quantum Development Kit for Visual Studio Code 0.8.19071701

Ranges with exclusive end

This issue has been create based on the issue originally filed by @Strilanc: #30

"My Q# programs are filled with unnecessary -1s because the slice a..b includes b instead of stopping at b-1. I recommend copying ruby and adding the alternative a...b to exclude b."

VS Code extension build failing on Mac

Describe the bug

Running Build-Dependencies.ps1 on Mac fails with an error "/bin/mkdir: illegal option -- P" and subsequent CopyContainerItemToLeafErrors when copying the published language server into the bin folder.

To Reproduce

Run Build-Dependencies.ps1 on Mac.

System information

  • Mac/Linus OS

Operations with the same specialization defined twice cause a language server error

Describe the bug

When an operation has the same specialization defined twice, the language server has an error:

[Error - 2:28:53 PM] 
=============================
error while running global type checking
QsCompilerException: error while running type checking in background
QsCompilerException: more than one specialization of the same kind exists
InvalidOperationException: Sequence contains more than one element
Stack trace: 
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 59

Stack trace: 
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message, Exception innerException) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 25
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 29
   at <StartupCode$Microsoft-Quantum-QsDataStructures>[email protected](String msg) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 58
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 61
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c.<BuildSpecializations>b__33_2(IGrouping`2 specs) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1153
   at System.Collections.Immutable.ImmutableDictionary.<>c__DisplayClass9_0`3.<ToImmutableDictionary>b__0(TSource element)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
   at System.Collections.Immutable.ImmutableDictionary`2.AddRange(IEnumerable`1 pairs, Boolean avoidToHashMap)
   at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildSpecializations(FragmentTree specsRoot, ResolvedSignature parentSignature, QsTuple`1 argTuple, NamespaceManager symbols, List`1 diagnostics, CancellationToken cancellationToken) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1151
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass34_1.<RunTypeChecking>g__GetSpecializations|6(KeyValuePair`2 specsRoot) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1297
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.RunTypeChecking(CompilationUnit compilation, ImmutableDictionary`2 roots, CancellationToken cancellationToken) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1323
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.<>c__DisplayClass27_0.<RunGlobalTypeChecking>b__0() in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\CompilationUnitManager.cs:line 483
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 59

Stack trace: 
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message, Exception innerException) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 25
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 29
   at <StartupCode$Microsoft-Quantum-QsDataStructures>[email protected](String msg) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 58
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 61
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.RunGlobalTypeChecking(CompilationUnit compilation, ImmutableDictionary`2 content, CancellationToken cancellationToken) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\CompilationUnitManager.cs:line 482
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.<>c__DisplayClass26_0.<SpawnGlobalTypeCheckingAsync>b__4() in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\CompilationUnitManager.cs:line 457
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure(Action action, String header) in C:\Users\t-samars\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 50
=============================

To Reproduce

This Q# file causes the error:

namespace Bug {
    operation Bug () : Unit {
        adjoint auto;
        adjoint auto;
    }
}

Expected behavior

The duplicate specialization should still have a red squiggly underline like it does now, but there shouldn't be a Q# language server error message.

Screenshots

System information

  • Visual Studio Code extension (Git master branch)
  • Windows 10 1809, .NET Core 2.1.701
  • Visual Studio Code 1.36.1

Additional context

Once excluded statements with muliple blocks are not re-included into the compilation

Describe the bug

For statement consisting of multiple blocks, mistyping one of headers causes the statement to be permanently excluded from compilation until the file is saved, allowing the editor to recover.

To Reproduce

Within an operation, type e.g.
sepeat {
let a = 10;
}
until (true);

Hover info for a is not showing any type info, since it's never compiled due to the mistyped repeat. That remains the case even after correcting the typo however.
The bug is more obvious e.g. for misplaced return statements, which prominently show a red underlining or lack thereof if they are not included in the compilation.

Expected behavior

Correcting the typo should result in the statement being included in the compilation, and all information and diagnostics being shown accurately.

System information

Irrelevant - the bug specifically exists up until the extension version 0.8.1907.1701.

Escape sequences in string literals are not interpreted

According to the documentation for strings in Q#, we should be able to write whitespace characters like \r\n and \t by using a backslash as the escape character, just like C# strings. I tried writing a few of these strings and called Message() with them:

operation StringEscapeTest () : Unit {
    Message("Normal line");
    Message("\tTab line");
    Message("\nNew line");
    Message("\r\nCRLF");
}

Produces this output:

Normal line
\tTab line
\nNew line
\r\nCRLF

It looks like the special characters aren't getting escaped properly.

Array Range Ellipsis Syntax Suggestions

We want to add code action that will simplify array index range expressions.

Examples:
"ary[0..2..Length(ary)-1]" would become "ary[...2...]"
"ary[Length(ary)-1..-2..0]" would become "ary[...-2...]"
"ary[5..2..Length(ary)-1]" would become "ary[5..2...]"
"ary[0..2..5]" would become "ary[...2..5]"
"ary[5..Length(ary)-1]" would become "ary[5...]"
"ary[0..5]" would become "ary[...5]"
"ary[0..Length(ary)-1]" would become "ary[...]"

Adding textDocument\foldingRange support for the language server

Is your feature request related to a problem? Please describe.
Being able to collapse long docstrings/adjacent single line comments/adjacent open statements into single lines can greatly improve readability (prime example: Quantum Katas, Basic Gates task).

Describe the solution you'd like
Support for the textDocument\foldingRange language server protocol message.

Describe alternatives you've considered
N/A

Additional context
Currently working on this for the OneWeek hackathon!

Support for qsproj files

We need to have a proper project system setup for Q# such that we can compiler and ship both Q# libraries and executable.

Investigate Project System

Investiage whether it makes sense to have our own project files and what that would entail regarding both the command line build and the integration into VS via the CPS.

IR specification

We need to formally define an IR format to compile into to facilitate a broader use. The expectation is that similarly to the compiler extensibility for transformations on top of the library format (see SyntaxTree.fs) today, it should be possible to plug into the compiler at this stage as well.

Stackoverflow for large files (20000+ lines of code)

File based on a bug reported to directly to me:

Describe the bug
The compiler fails with a stackoverflow for long files (more than 20000 lines of code).

To Reproduce
Source code to reproduce the problem was provided via the appropriate channels.

System information
irrelevant

Operation Inlining

We gradually want to incorporate some of the compilation steps and optimizations usually done for classical programming languages (opposed to quantum programming languages) into the Q# compiler. While our focus is naturally on different aspects of a program when compiling and optimizing for execution on a quantum processor, we still need some of the classical infrastructure as well.
In particular, we want some infrastructure for inlining operations.

Trying to use an open range on a non-array type causes a compiler exception

Describe the bug

Trying to use an open range expression (x[1...]) when x is not an array type (e.g., Qubit instead of Qubit[]) causes the compiler to throw an exception and the Visual Studio Code extension says the language server encountered an error.

[Error - 9:39:30 PM] 
=============================
error while running queued task
QsCompilerException: error during type checking update
QsCompilerException: error on running type checking
ArgumentException: the given expression is not of array type
Stack trace: 
   at Microsoft.Quantum.QsCompiler.SyntaxGenerator.Length(TypedExpression ex) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\Core\SyntaxGenerator.fs:line 134
   at Microsoft.Quantum.QsCompiler.SyntaxGenerator.LengthMinusOne(TypedExpression ex) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\Core\SyntaxGenerator.fs:line 140
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Expressions.OpenEndInSlicing@604.Invoke(FSharpOption`1 _arg2) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\ExpressionVerification.fs:line 606
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Expressions.resolveWith@613.Invoke(FSharpFunc`2 build, QsExpression ex) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\ExpressionVerification.fs:line 613
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Expressions.rangeWithStep@608.Invoke(Tuple`3 tupledArg) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\ExpressionVerification.fs:line 614
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Expressions.buildArrayItem@592.Invoke(Tuple`2 tupledArg) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\ExpressionVerification.fs:line 624
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Expressions.QsExpression.Resolve[a](QsExpression this, SymbolTracker`1 symbols, FSharpFunc`2 addDiagnostic) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\ExpressionVerification.fs:line 814
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Statements.VerifyWith[a,b,c](FSharpFunc`2 verification, SymbolTracker`1 symbols, QsExpression expr) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\StatementVerification.fs:line 29
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Statements.Verify[a](SymbolTracker`1 symbols, QsExpression expr) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\StatementVerification.fs:line 36
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Statements.NewBinding[a](QsBindingKind kind, QsComments comments, QsLocation location, SymbolTracker`1 symbols, QsSymbol qsSym, QsExpression qsExpr) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\StatementVerification.fs:line 173
   at Microsoft.Quantum.QsCompiler.SyntaxProcessing.Statements.NewImmutableBinding[a](QsComments comments, QsLocation location, SymbolTracker`1 symbols, QsSymbol qsSym, QsExpression qsExpr) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\SyntaxProcessor\StatementVerification.fs:line 187
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass24_0.<TryBuildLetStatement>b__0(QsLocation relPos, SymbolTracker`1 symbols) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 791
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildStatement[T](TreeNode node, Func`3 build, SymbolTracker`1 symbolTracker, List`1 diagnostics) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 491
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.TryBuildLetStatement(IEnumerator`1 nodes, SymbolTracker`1 symbolTracker, List`1 diagnostics, Boolean& proceed, QsStatement& statement) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 790
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildStatements(IEnumerator`1 nodes, SymbolTracker`1 symbolTracker, List`1 diagnostics) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 997
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildScope(IReadOnlyList`1 nodeContent, SymbolTracker`1 symbolTracker, List`1 diagnostics) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 470
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildUserDefinedImplemenation(TreeNode root, NonNullable`1 sourceFile, QsTuple`1 argTuple, SymbolTracker`1 symbolTracker, List`1 diagnostics) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1073
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass33_0.<BuildSpecializations>g__BuildSpecialization|4(QsSpecializationKind kind, ResolvedSignature signature, QsSpecializationGeneratorKind`1 gen, TreeNode root, Func`2 buildArg, QsComments comments) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1179
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass33_0.<BuildSpecializations>g__BuildSpec|5(TreeNode root) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1202
   at System.Linq.Enumerable.SelectIListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Immutable.ImmutableArray`1.Builder.AddRange(IEnumerable`1 items)
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.BuildSpecializations(FragmentTree specsRoot, ResolvedSignature parentSignature, QsTuple`1 argTuple, NamespaceManager symbols, List`1 diagnostics, CancellationToken cancellationToken) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1232
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass34_1.<RunTypeChecking>g__GetSpecializations|6(KeyValuePair`2 specsRoot) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1296
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items)
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.RunTypeChecking(CompilationUnit compilation, ImmutableDictionary`2 roots, CancellationToken cancellationToken) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1322
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.<>c__DisplayClass36_1.<UpdateTypeChecking>b__1() in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1430
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 59

Stack trace: 
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message, Exception innerException) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 25
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 29
   at <StartupCode$Microsoft-Quantum-QsDataStructures>[email protected](String msg) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 58
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure[T](Func`1 func, String header) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 61
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.TypeChecking.UpdateTypeChecking(FileContentManager file, CompilationUnit compilation) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\TypeChecking.cs:line 1430
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.FileContentManager.<>c__DisplayClass66_0.<Verify>b__0() in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\FileContentManager.cs:line 779
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure(Action action, String header) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 50

Stack trace: 
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message, Exception innerException) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 25
   at Microsoft.Quantum.QsCompiler.QsCompilerError.Raise(String message) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 29
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure(Action action, String header) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 52
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.FileContentManager.Verify(CompilationUnit compilation) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\FileContentManager.cs:line 779
   at Microsoft.Quantum.QsCompiler.CompilationBuilder.CompilationUnitManager.<>c__DisplayClass20_0.<TriggerFileUpdateAsync>b__0() in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\CompilationManager\CompilationUnitManager.cs:line 320
   at Microsoft.Quantum.QsCompiler.QsCompilerError.RaiseOnFailure(Action action, String header) in C:\Users\marsh\source\repos\qsharp-compiler\src\QsCompiler\DataStructures\ErrorHandling.fs:line 50
=============================

To Reproduce

Try this code with the language server running:

namespace Bug {
    operation Bug (x : Qubit) : Unit {
        let y = x[1...];
    }
}

Expected behavior

This code is invalid, so it should produce a diagnostic, but it shouldn't throw an internal compiler error.

Screenshots

N/A

System information

  • Git master version
  • Windows 10, .NET Core 2.2.301
  • Visual Studio Code 1.37.0

Additional context

N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.