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

Trait method not found when working on inferred integer type #3051

Closed
jfecher opened this issue Oct 9, 2023 · 0 comments · Fixed by #4815
Closed

Trait method not found when working on inferred integer type #3051

jfecher opened this issue Oct 9, 2023 · 0 comments · Fixed by #4815
Labels
bug Something isn't working
Milestone

Comments

@jfecher
Copy link
Contributor

jfecher commented Oct 9, 2023

Aim

trait Foo {
    fn foo(self) -> Field;
}

impl Foo for Field {
    fn foo(self) -> Field {
        self + 1
    }
}

fn main() {
    dep::std::println(1.foo());
}

Expected Behavior

The given code should compile and run

Bug

An error is issued:

error: No method named 'foo' found for type 'Field'
   ┌─ /.../short/src/main.nr:68:2368dep::std::println(1.foo());
   │                       -------
   │

We should match rust's behavior here. At the time 1.foo() is called, there is only 1 applicable impl, so we should select that one and set the type of 1 appropriately.

The likely reason this doesn't already work is that integer literals in noir are polymorphic (generic), and the use of generics with traits isn't yet implemented.

To Reproduce

Installation Method

None

Nargo Version

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 bug Something isn't working label Oct 9, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 9, 2023
@kevaundray kevaundray added this to the 1.0 milestone Jan 15, 2024
TomAFrench added a commit that referenced this issue Apr 16, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 26, 2024
# Description

## Problem\*

Resolves #3051

## Summary\*

This issue has been fixed and so I'm added a regression test.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Apr 26, 2024
TomAFrench added a commit that referenced this issue May 1, 2024
* master: (25 commits)
  feat: Complex outputs from acir call (#4952)
  fix: Require for all foldable functions to use distinct return  (#4949)
  feat!: use `distinct` return value witnesses by default (#4951)
  chore(docs): adding matomo tracking (#4898)
  chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (#4933)
  chore: Add test for recursing a foldable function (#4948)
  feat: Handle `no_predicates` attribute (#4942)
  fix: ensure where clauses propagated to trait default definitions (#4894)
  chore: Remove unnecessary `pub(super)` in interpreter (#4939)
  feat: add de-sugaring for `impl Trait` in function parameters (#4919)
  feat(experimental): `comptime` globals (#4918)
  chore: update error conversion traits to act on references (#4936)
  fix: ban self-referential structs (#4883)
  chore: add regression test for #3051 (#4815)
  fix: discard ref counts during unrolling (#4923)
  feat!: Bit shift is restricted to u8 right operand (#4907)
  feat: Add `#[inline(tag)]` attribute and codegen (#4913)
  chore: rework workspace structure for utils crates (#4886)
  feat: add variable size sha256 (#4920)
  chore: delete flake.lock (#4855)
  ...
TomAFrench added a commit that referenced this issue May 1, 2024
* master: (25 commits)
  feat: Complex outputs from acir call (#4952)
  fix: Require for all foldable functions to use distinct return  (#4949)
  feat!: use `distinct` return value witnesses by default (#4951)
  chore(docs): adding matomo tracking (#4898)
  chore: fix typo in `ResolverError::AbiAttributeOutsideContract` (#4933)
  chore: Add test for recursing a foldable function (#4948)
  feat: Handle `no_predicates` attribute (#4942)
  fix: ensure where clauses propagated to trait default definitions (#4894)
  chore: Remove unnecessary `pub(super)` in interpreter (#4939)
  feat: add de-sugaring for `impl Trait` in function parameters (#4919)
  feat(experimental): `comptime` globals (#4918)
  chore: update error conversion traits to act on references (#4936)
  fix: ban self-referential structs (#4883)
  chore: add regression test for #3051 (#4815)
  fix: discard ref counts during unrolling (#4923)
  feat!: Bit shift is restricted to u8 right operand (#4907)
  feat: Add `#[inline(tag)]` attribute and codegen (#4913)
  chore: rework workspace structure for utils crates (#4886)
  feat: add variable size sha256 (#4920)
  chore: delete flake.lock (#4855)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants