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

compile error with generic function: cannot find type parameter in scope #2424

Closed
ghost opened this issue Aug 24, 2023 · 3 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ghost
Copy link

ghost commented Aug 24, 2023

Aim

fn hello<N>() {
    for i in 0..N {}
}

Expected Behavior

The code should compile successfully since the generic type parameter N is correctly defined in the function signature.

Bug

When trying to compile a function with a generic type parameter, the compiler reports that it cannot find the type parameter N within the scope, even though it should be correctly defined.

error: cannot find `N` in this scope 
   ┌─ array.nr:97:17
   │
97 │     for i in 0..N {}
   │                 - not found in this scope
   │

To Reproduce

Installation Method

Compiled from source

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@ghost ghost added the bug Something isn't working label Aug 24, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 24, 2023
@jfecher
Copy link
Contributor

jfecher commented Aug 24, 2023

I think the issue is in how we identify/infer numeric type variables currently. They're only added to scope if after checking the function signature we can actually confirm they're numeric by finding them in an array length somewhere.

@kevaundray kevaundray added this to the 0.25 milestone Jan 15, 2024
@kevaundray kevaundray added the good first issue Good for newcomers label Jan 15, 2024
@Savio-Sou
Copy link
Collaborator

@f01dab1e is this still relevant?

@Savio-Sou Savio-Sou removed this from the 0.25 milestone Mar 12, 2024
@TomAFrench
Copy link
Member

Duplicate of #4633

@TomAFrench TomAFrench marked this as a duplicate of #4633 Apr 4, 2024
@TomAFrench TomAFrench closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

4 participants