Skip to content

Create a subtype framework for the typechecker #14

@sbarara3

Description

@sbarara3

Currently, there exists no framework for the typechecker to recognize when certain types inherit from other types. This leads to issues where valid qwerty code is not accepted by the compiler due to the typechecker throwing errors. Take for example the following qwerty code:

from qwerty import *

@qpu
def kernel() -> bit:
    f = pm.project if '+'|measure else id
    q = '0'|f|std.project|f
    return q|measure

print(kernel())

This produces the following error:

error: 'scf.if' op  along control flow edge from Region #1 to parent results:
source type #0 '!qwerty<func(!qwerty<qbundle[1]>) rev-> !qwerty<qbundle[1]>>' should match input type #0 '!qwerty<func(!qwerty<qbundle[1]>) irrev-> !qwerty<qbundle[1]>>'

This happens because the typechecker does not correctly recognize the type-subtype relationship between irreversible and reversible functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions