Skip to content

Remove const bool flag from qsc_openqasm_compiler::types::Type#3004

Merged
minestarks merged 2 commits intominestarks/fix-bit-binop-result-castfrom
copilot/sub-pr-2990
Mar 6, 2026
Merged

Remove const bool flag from qsc_openqasm_compiler::types::Type#3004
minestarks merged 2 commits intominestarks/fix-bit-binop-result-castfrom
copilot/sub-pr-2990

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

The Type enum in qsc_openqasm_compiler carried a bool const qualifier on most variants (e.g. Int(bool), Result(bool), BoolArray(ArrayDimensions, bool)). Since Q# has no const bindings, this flag was never meaningful in the Q# type representation and only added noise — requiring a dedicated without_const() method just to normalize types for equality comparisons.

Changes

  • types.rs: Strip the bool const parameter from all Type variants; remove without_const().
  • compiler.rs:
    • semantic_type_for_qsharp_type: no longer extracts or forwards is_const into Type construction.
    • make_qsharp_array_ty: removes hardcoded false const args.
    • maps_to_same_qsharp_type: simplifies to direct == comparison (the note about ignoring const qualifiers is now moot).
  • ast_builder.rs: map_qsharp_type_to_ast_ty updated to match new variant shapes.
// Before
pub enum Type {
    Int(bool),
    Result(bool),
    ResultArray(ArrayDimensions, bool),
    // ...
}

// After
pub enum Type {
    Int,
    Result,
    ResultArray(ArrayDimensions),
    // ...
}

Constness is still read from the OpenQASM parser symbol (symbol.ty.is_const()) where it matters — to decide Q# declaration mutability (let vs mutable) — it just no longer flows into the intermediate Type representation.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: minestarks <16928427+minestarks@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix redundant round-trip casts in OpenQASM-to-Q# compilation Remove const bool flag from qsc_openqasm_compiler::types::Type Mar 6, 2026
@minestarks minestarks marked this pull request as ready for review March 6, 2026 23:50
@minestarks minestarks merged commit 111ddf2 into minestarks/fix-bit-binop-result-cast Mar 6, 2026
2 checks passed
@minestarks minestarks deleted the copilot/sub-pr-2990 branch March 6, 2026 23:50
@microsoft microsoft deleted a comment from EmmiitBrown Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants