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

Functors in declaration can contradict functor generators #546

Open bamarsha opened 4 years ago

bamarsha commented 4 years ago
operation Foo() : Unit is Adj {
    body (...) { }
    controlled auto;
}

Based on the declaration, this operation appears to support only Adj. Based on the functor generators, it appears to support only Ctl. It actually supports both Adj and Ctl.

I think it would be less confusing if this code was invalid. Maybe if an explicit functor list is present in the declaration, it must match exactly, or be a superset of, the functor generators?

bettinaheim commented 4 years ago

@samarsha This is actually by design and the reason having been backward compatibility. It may make sense to revisit that, but it is intentional and according to spec (the spec was that the annotation may contain a partial annotation, even though that may potentially be confusing).

bamarsha commented 4 years ago

Thanks for the explanation, looking forward to having a public Q# specification where I can look for things like this. :)