forked from microsoft/qsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add opt-in language features to the Qsharp.json manifest (microsoft#1089
) Closes microsoft#543 ## Overview This PR adds two things: 1. The ability to opt-in to language features via the project manifest, `qsharp.init()`, or command-line flags 2. A simple feature, `v2-preview-syntax`, ostensibly created to allow users to opt-in to breaking syntax that's coming in the future, but really created so I could wire up and show how a real language feature works. Only one syntax change was made in this feature: removal of scoped qubit blocks. This is because a scoped qubit block is identical to a scoped block with a qubit in it. `use qubit = Qubit () {};` is equivalent to `{ use qubit = Qubit(); }`. We therefore prefer the latter. ## Implementation Notes This PR includes the addition of `ParserContext`. It became clear to me that language features need to be globally available to _at least_ the parser, and probably other areas of the compiler later. Instead of plumbing this all around manually as an argument, I promoted `Scanner` into a `ParserContext`. This PR also refactors manifest loading in `projectSystem.ts` -- we had some duplicate code in `getManifestThrowsOnParseFailure` and `getManifest`. I DRY'd that up. ## FAQ ### Why opt-in features? In our discussions of evolving the language, it became clear that we prioritize both improving the language, including in breaking ways, and maintaining compatibility. As a result, introducing the notion of being able to opt-in to a specific language feature became a blocker for most further language design work. ### How will packages with different feature sets work together? In general, we should aim to write features that don't break compatibility with other packages. The language server and all compiler scenarios assess language features on a per-package basis, so as long as the individual compilation units are sane and well-formed, their feature sets should be interoperable. ## Tests These tests are considered _passing_ if turning on the language feature `v2-preview-syntax` causes the compiler to reject scoped qubit block syntax. ✅ Histogram: https://github.com/microsoft/qsharp/assets/12157751/631dded2-d016-4933-83fe-bdff67852f50 ✅ Language Service https://github.com/microsoft/qsharp/assets/12157751/964574f6-c6bd-4225-acd4-6eb2afaec41c ✅ Jupyter Notebook https://github.com/microsoft/qsharp/assets/12157751/fc5cc8b8-1c47-4dd9-b478-a233f16fc9e3 ✅ `qsc` https://github.com/microsoft/qsharp/assets/12157751/48e746fc-f7fe-4e9a-a658-d428b640d062 ✅ `qsi` https://github.com/microsoft/qsharp/assets/12157751/8154de70-80c5-444c-ac4e-f33d775a2fa9 ✅ Debugger https://github.com/microsoft/qsharp/assets/12157751/5aa7fb5a-3ec4-43fe-b256-6b75c808fe7e ✅ Language service inside of notebook cells ![image](https://github.com/microsoft/qsharp/assets/12157751/b710cc71-ce7d-4732-8acb-f315778239a1) ✅ QIR Generation https://github.com/microsoft/qsharp/assets/12157751/eed50ca5-85c4-4434-9443-a6c67ef10337
- Loading branch information
Showing
77 changed files
with
1,308 additions
and
363 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.