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

Cannot use type aliases of structs in paths #4469

Closed
jfecher opened this issue Mar 4, 2024 · 1 comment · Fixed by #6399
Closed

Cannot use type aliases of structs in paths #4469

jfecher opened this issue Mar 4, 2024 · 1 comment · Fixed by #6399
Assignees
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Mar 4, 2024

Aim

use std::{collections::map::HashMap, hash::{BuildHasherDefault, poseidon::PoseidonHasher}};

type Alias = HashMap<Field, Field, 10, BuildHasherDefault<PoseidonHasher>>;

fn main() {
    let map1 = HashMap::default();

    // panic here
    let map2 = Alias::default();
}

Expected Behavior

To be able to use Alias anywhere HashMap is expected, including in paths

Bug

The application panicked (crashed).
Message:  type aliases cannot be used in type namespace
Location: compiler/noirc_frontend/src/hir/resolution/import.rs:159

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml
exit 101

To Reproduce

Project Impact

None

Impact Context

No response

Workaround

Yes

Workaround Description

The original type (HashMap in this case) must be used instead of the alias

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@asterite
Copy link
Collaborator

To be able to work on this we first need to implement #6000.

The reason is that we can solve the alias but it solves to a type that has concrete generics, and then we are calling a method on that... but we don't have code yet to support that, so we first need to implement that.

@asterite asterite self-assigned this Oct 22, 2024
@asterite asterite moved this from 📋 Backlog to 🚧 Blocked in Noir Oct 24, 2024
@asterite asterite changed the title Cannot use type aliases in paths Cannot use type aliases of structs in paths Oct 30, 2024
@github-project-automation github-project-automation bot moved this from 🚧 Blocked to ✅ Done in Noir Oct 30, 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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants