Integer division for casts, int array elements, bitwise results, ** and int-returning subroutines

Open
#480 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
compilers

Research direction

Start from the integer-division handling added in #474 and the type rules in language/types.rst and language/classical.rst. Locate where binary / is typed and where casts, array indexing, bitwise/shift results, **, and int/uint subroutine returns get their types, then add regression cases for the four snippets in the issue. Done when each snippet uses integer division and existing division tests still pass.

Written by the indexing model from the issue text.

Description

After #474, / divides as integers when both operands are integer literals or int/uint variables. Other integer-typed operands still use true division:

OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
int[32] a = 2;
int[32] b = 3;
float[64] f = 7.9;
array[int[32], 2] arr = {7, 1};
def h() -> int[32] { return 7; }
rx(int[32](f) / a) q[0];   // rx(3.5), spec gives 3
rx(arr[0] / a) q[0];       // rx(3.5), spec gives 3
rx((b | 4) / a) q[0];      // rx(3.5), spec gives 3
rx(h() / a) q[0];          // rx(3.5), spec gives 3

Casts to int/uint, elements of integer arrays, bitwise and shift results on integers, int ** int, and subroutines that return int/uint are all integer-typed in the spec (language/types.rst, language/classical.rst). Raised in the review of #474.

Dominant language
Python
Stars
29
Forks
33
Avg merge
1d 20h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from qBraid/pyqasm

All issues in qBraid/pyqasm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.