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

feat(traits): Type checking for Trait impl method signatures #2652

Merged
merged 12 commits into from
Sep 19, 2023

Conversation

alexvitkov
Copy link
Contributor

@alexvitkov alexvitkov commented Sep 12, 2023

Description

Summary

This is further work on traits (#2568).

  1. Moved Trait-related HIR structs out of (hir_def/types.rs) into a new file (hir_def/traits.rs). This is mostly why the PR looks pretty big
  2. Added signature checking for methods in an impl block - They must have a corresponding method in the Trait with matching parameters & return type.
  3. To handle typechecking for Self, a type variable is added in the Trait struct, which has to get bound to the concrete self type before we do the signature check mentioned above

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@alexvitkov alexvitkov changed the title Traits impl methods typecheck feat(traits): Type checking for Trait impl method signatures Sep 12, 2023
@alexvitkov alexvitkov force-pushed the traits-impl-methods-typecheck branch from d270dde to 5f4539a Compare September 15, 2023 05:59
@alexvitkov alexvitkov force-pushed the traits-impl-methods-typecheck branch from 5f4539a to 40052a9 Compare September 18, 2023 12:32
Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. Can you move the type checking portion to the type checking pass rather than include it during name resolution?

Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can save moving the type checking to a later PR when it is easier to do so, as you mentioned. 👍

@jfecher jfecher added this pull request to the merge queue Sep 19, 2023
Merged via the queue into noir-lang:master with commit 8617008 Sep 19, 2023
TomAFrench added a commit that referenced this pull request Sep 20, 2023
* master:
  feat(traits): Type checking for Trait impl method signatures  (#2652)
  chore: split 9_conditional test case and remove 8_integration (#2751)
  chore(github): Add "Idea Action Plan" Issue template (#2736)
  feat(aztec-noir): abstract storage (#2750)
  feat: signed arithmetic (#2748)
  chore: encapsulate abstraction leaks from `bb` into new crate (#2747)
  feat: Variable liveness analysis for brillig (#2715)
  chore: noirjs integration testing (#2744)
  chore: Add rust-toolchain file & adapt nix for changes (#2686)
  chore: wrap backend info response in a struct instead of boxed closure (#2737)
  fix: check for literal overflows in expressions (#2742)
  fix: nightly js test (#2740)
  fix: keep the correct type for bitshift (#2739)
  chore: Make new daily nightly releases be pre-releases and non latest (#2735)
  chore: disabling display location section  (#2118)
  chore: add a workflow that tracks acvm version for integration tests (#2700)
  feat: Save nightly build in github releases with date tags (#2416)
  chore: Add unified linting setup for JS code and enforce in CI (#2728)
@nickysn nickysn mentioned this pull request Sep 21, 2023
46 tasks
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