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

Enum variants with no fields must still be called like functions #7172

Closed
jfecher opened this issue Jan 23, 2025 · 0 comments · Fixed by #7183
Closed

Enum variants with no fields must still be called like functions #7172

jfecher opened this issue Jan 23, 2025 · 0 comments · Fixed by #7183
Assignees
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Jan 23, 2025

Aim

fn main() {
    let _foo: Foo = Foo::Bar;
}

enum Foo {
    Bar
}

Expected Behavior

The program to compile

Bug

error: Expected type Foo, found type fn() -> Foo
  ┌─ src/main.nr:2:21
  │
2 │     let _foo: Foo = Foo::Bar;
  │                     --------
  │

The compiler treats Foo::Bar as a function despite it being declared as Bar instead of Bar().

Fixing this requires a new type of definition in Noir since Foo::Bar would normally be a global constant with its tag value, but this does not work for generic types since Noir doesn't support generic globals.

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the bug Something isn't working label Jan 23, 2025
@jfecher jfecher self-assigned this Jan 23, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 23, 2025
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jan 31, 2025
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.

1 participant