Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Some valid Q# callable names produce invalid C# code #241

@bamarsha

Description

@bamarsha

The classes generated for Q# callables contains several built-in members with names that are not surrounded by __. This means they are valid Q# identifiers. If you declare a Q# callable with the same name as one of these members, the C# code does not compile because the member name conflicts with the constructor name.

Here is an example:

function Init() : Unit {
    Message("Hello quantum world!");
}

produces this C# compile error:

Program.qs(22,30): error CS0542: '"Init": member names cannot be the same as their enclosing type.

Here is a list of names I tried that are valid Q# but produce invalid C#:

  • Body
  • AdjointBody if the operation is adjointable.
  • ControlledBody if the operation is controllable.
  • ControlledAdjointBody if the operation is controllable and adjointable.
  • Info
  • Init
  • Run
  • __dataIn
  • __dataOut
  • The fully qualified name of any callable used, with dots removed, such as MicrosoftQuantumIntrinsicMessage for the example above.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions