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

Compiler panic: type aliases cannot be used in type namespace #5005

Closed
LogvinovLeon opened this issue May 9, 2024 · 1 comment
Closed

Compiler panic: type aliases cannot be used in type namespace #5005

LogvinovLeon opened this issue May 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LogvinovLeon
Copy link
Contributor

Aim

This code should compile without breaking the compiler:

type Bytes32 = [u8; 32];

trait Hello {
    fn hello(self) -> Field {}
}

impl Hello for Bytes32 {
    fn hello(self) -> Field {
        1
    }
}

fn main(x: pub Field) {
    let value: Bytes32 = [0; 32];
    let y = Bytes32::hello(value);
    assert(y == x);
}

Expected Behavior

Compiles

Bug

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

To Reproduce

  1. Try to compile

Project Impact

Nice-to-have

Impact Context

I'm implementing my own Serde and because of this bug - I can't use consistent syntax, but need to switch and use Type::serialize(x) for structs and x.serialize() for Bytes32.

    fn deserialize(data: [Field; STORAGE_WITHIN_BLOCK_1_SERIALIZED_LEN]) -> Self {
        let mut fragment = Fragment::new_focused(data);
        let block_hash = fragment.pop_front_array().deserialize();
        let account = Account::deserialize(fragment.pop_front_array());
        let values = [fragment.pop_front_array().deserialize()];
        StorageWithinBlock {
            block_hash,
            account,
            values,
        }
    }

Workaround

Yes

Workaround Description

As described above

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

nargo version = 0.28.0

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher
Copy link
Contributor

jfecher commented May 9, 2024

Duplicate of #4469

@jfecher jfecher marked this as a duplicate of #4469 May 9, 2024
@jfecher jfecher closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir May 9, 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

No branches or pull requests

2 participants