microsoft / qsharp-compiler

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

Compiler should auto-open the Canon and Intrinsic namespaces along with Core #1550

Open swernli opened 2 years ago

swernli commented 2 years ago

Right now the compiler only auto-opens Microsoft.Quantum.Core, but IQ# for convenience in notebook scenarios opens both Microsoft.Quantum.Canon and Microsoft.Quantum.Intrinsic. These two are also part of the default new program created by the QDK. Instead of requiring local developers to add these while notebook developers don't and needing to have the discrepancy handled by the language server used across both scenarios, we can have the compiler auto-open all three namespaces.

This would be a breaking change for only very specific code if it previously did not open one of these namespaces and then defined callables or UDTs that share a name with those in Canon or Intrinsic. If those are not intended as overrides, they will need alias or fully qualified names. However, if they are intended as overrides, the accepted mechanism for overriding items from a namespace is to use one or more target packages. This means that the IsTargetPackage assembly property should be used to disable all auto-open behavior, and existing target packages would be updated to manually open the Core namespace.