-
Notifications
You must be signed in to change notification settings - Fork 370
Milestone
Description
Aim
I attempted to compile the following program:
trait Foo {
type Bar;
}
pub struct Example { }
pub struct Baz { }
impl Foo for Example {
type Bar = Baz;
}
impl Foo::Bar { }
fn main() { }And got:
❯ ~/.nargo/bin/nargo compile
error: Ambiguous associated type
┌─ src/main.nr:12:6
│
12 │ impl Foo::Bar { }
│ -------- If there were a type named `Example` that implemented `Foo`, you could use the fully-qualified path: `<Example as Foo>::Bar`
│
So then I attempted to compile the following program:
trait Foo {
type Bar;
}
pub struct Example { }
pub struct Baz { }
impl Foo for () {
type Bar = Baz;
}
impl <Example as Foo>::Bar { }
fn main() { }Expected Behavior
I expected compilation to fail with a type error or an error that mentioned the use of <.. as Foo>::Bar in an impl
Bug
❯ ~/.nargo/bin/nargo compile
error: The type parameter `Example` is not constrained by the impl trait, self type, or predicates
┌─ src/main.nr:12:7
│
12 │ impl <Example as Foo>::Bar { }
│ ------- Hint: remove the `Example` type parameter
│
error: Expected a generic parameter but found 'as'
┌─ src/main.nr:12:15
│
12 │ impl <Example as Foo>::Bar { }
│ --
│
error: Expected a type but found 'as'
┌─ src/main.nr:12:15
│
12 │ impl <Example as Foo>::Bar { }
│ --
│
error: Expected a '{' but found 'as'
┌─ src/main.nr:12:15
│
12 │ impl <Example as Foo>::Bar { }
│ --
│
error: Expected an item but found 'as'
┌─ src/main.nr:12:15
│
12 │ impl <Example as Foo>::Bar { }
│ --
│
error: Expected an item but found 'Foo'
┌─ src/main.nr:12:18
│
12 │ impl <Example as Foo>::Bar { }
│ ---
│
error: Expected an item but found '>'
┌─ src/main.nr:12:21
│
12 │ impl <Example as Foo>::Bar { }
│ -
│
error: Expected an item but found '::'
┌─ src/main.nr:12:22
│
12 │ impl <Example as Foo>::Bar { }
│ --
│
error: Expected an item but found 'Bar'
┌─ src/main.nr:12:24
│
12 │ impl <Example as Foo>::Bar { }
│ ---
│
error: Expected an item but found '{'
┌─ src/main.nr:12:28
│
12 │ impl <Example as Foo>::Bar { }
│ -
│
error: Expected an item but found '}'
┌─ src/main.nr:12:30
│
12 │ impl <Example as Foo>::Bar { }
│ -
│
Aborting due to 11 previous errors
To Reproduce
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Nargo Version
nargo version = 1.0.0-beta.16 noirc version = 1.0.0-beta.16+a5edaa61161198bd1f0f66952c671bc879366dfd (git version hash: a5edaa6, 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