Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Type::TypeVariable, Type::PolymorphicInteger, and all other type variables with one kind #1991

Closed
jfecher opened this issue Jul 20, 2023 · 1 comment · Fixed by #2065
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request refactor

Comments

@jfecher
Copy link
Contributor

jfecher commented Jul 20, 2023

Problem

As the typechecker grows it can be useful to have different kinds of type variables. E.g. variables that can bind to anything, or only integer types, or integer and field types, etc. However, for these cases we currently have to create an entirely new variant of Type each time and implement most cases the same way.

Happy Case

We should only have Type::TypeVariable, and it should contain an internal enumeration TypeVariableKind detailing what kind of type variable it is. This will allow us to add and work with type variables more easily without bloating our Type representation. Example of this enum:

enum TypeVariableKind {
    /// Can bind to any type
    Normal,
    /// Can only bind to integer types (not including fields). Used for comparison and bitwise operations
    Integer,
    /// Can bind to integer or field types. Used for most arithmetic operations.
    IntegerOrField,
    /// Can only bind to constant integers e.g. array sizes.
    Constant,
}

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label Jul 20, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 20, 2023
@jfecher jfecher added refactor compiler frontend `noirc_frontend` crate labels Jul 20, 2023
@kevaundray
Copy link
Contributor

@f01dab1e feel free to take this on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request refactor
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants