Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.46k stars 159 forks source link

Add is_equal to TyTy types #187

Closed philberty closed 3 years ago

philberty commented 3 years ago

Currently to check if types are equal or can be unified we call combine. This is inefficient for many cases like FnTypes we want a strict is_equal check.

We can add this as an abstract method to the TyTy::TyBase, it might be worth renaming this class at the same time as the name bugs me.

RuchiGitHu commented 3 years ago

Good Evening, I want to fix the issue but this is my first step towards contributing in open source project. Please let me know about this issue. Thanks in advance..

philberty commented 3 years ago

Hi @RuchiGitHu thanks for your interest. Please be aware in this project we require contributors to follow the copyright assignment process https://gcc.gnu.org/contribute.html

There are 2 parts to this issue.

  1. Where inside https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/typecheck/rust-tyty.h we rename and refactor the usage of TyBase I think the name is bad at the moment, maybe call it BaseType. It represents the abstract base class for all potential types within the rust language. Such as ADTType which is the algebraic data type to represent structs for example. The purpose here is a cleanup effort on naming.
  2. The next piece is we need to add a new virtual method to this BaseType class in the same file called: virtual bool is_equal(TypeBase&other) const {} For now this can be implemented within the base class like this { return get_type() == other.get_type(); }

Some more thought is needed once this block of work is in as to where we use this instead of calling combine to unify types.

Hope this helps.

RuchiGitHu commented 3 years ago

Thanks @philberty for the information you provided to me. I will try to fix it.

philberty commented 3 years ago

Fixed in #238