microsoft / qsharp-compiler

Q# compiler, command line tool, and Q# language server
https://docs.microsoft.com/quantum
MIT License
684 stars 171 forks source link

Update syntax checking to require no namespace{}s in notebooks #1481

Closed ausbin closed 2 years ago

ausbin commented 2 years ago

This is a smaller PR for syntax checking (no semantic checking) for namespace{} blocks in notebooks, because #1457 was getting out of control.

Magic commands are broken in this code, but that is out of scope for this PR. The goal here is to get this code for syntax checking for namespace{} blocks (which hasn't changed too much in several weeks) reviewed and merged into the feature branch.

Testing

ausbin commented 2 years ago

Posting another revision based on what we talked about today. Tested again manually with Azure Notebooks and running dotnet test.

I am hitting #1470 again locally with .NET SDK 6.0.302, so I had to manually lock my local global.json(s) at 6.0.301. Oh me.

ausbin commented 2 years ago

Rebased this against main and #1462 has left the language server tests in a broken state. To test this locally, I applied the following hack:

diff --git a/src/QsCompiler/LanguageServer/global.language-server.json b/src/QsCompiler/LanguageServer/global.language-server.json
index 3b31a29a..2a1043b5 100644
--- a/src/QsCompiler/LanguageServer/global.language-server.json
+++ b/src/QsCompiler/LanguageServer/global.language-server.json
@@ -1,6 +1,5 @@
 {
   "sdk": {
-    "version": "6.0.302",
-    "rollForward": "latestPatch"
+    "version": "6.0.301"
   }
 }
filipw commented 2 years ago

is this a "hack" to make notebook experience nice, or is this something that will be "officially" reflected in the language specification too (no mandatory namespace declaration in certain contexts)?

ausbin commented 2 years ago

@filipw I would call this a hack at the moment, specifically to make Q# IntelliSense work on Azure Notebooks.

We have discussed adding this to the Q# spec as "REPL mode", but that's out of my pay grade. The language changes would be: