Skip to content

Wrong error message when using generics in main #8456

Description

@michaeljklein

Aim

Attempted to compile a program where main has a generic argument:

fn main<let F: u32>(x: [Field; F]) {
    assert(x[0] != x[1]);
}

Expected Behavior

Expected compilation to fail with an accurate user error

Bug

~/.nargo/bin/nargo compile
error: Only sized types may be used in the entry point to a program
  ┌─ src/main.nr:1:24
  │
1 │ fn main<let F: u32>(x: [Field; F]) {
  │                        ---------- Slices, references, or any type containing them may not be used in main, contract functions, or foldable functions
  │

Aborting due to 1 previous error

(There are no slices, references, or any type containing them in the program.)

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

Nice-to-have

Blocker Context

No response

Nargo Version

nargo version = 1.0.0-beta.5 noirc version = 1.0.0-beta.5+944d23430d2746e25980ca283160f13665f123c3 (git version hash: 944d234, is dirty: false)

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions