You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Description
## Problem\*
Resolves#3773
Part of #2568
## Summary\*
This PR implements the ability to be able to call trait methods such as
`Default::default()` where previously we required
`StructName::default()`. The specific impl is selected via type
inference. Previously, this resulted in a compiler panic.
## Additional Context
When a trait method's type isn't constrained enough or is otherwise
still ambiguous after type inference, the compiler currently just
selects the first trait implementation that matches. E.g. `let _ =
Default::default();`. This is a separate issue, so I'll create a new
issue for this.
## Documentation\*
Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [x] **[Exceptional Case]** Documentation to be submitted in a separate
PR.
- I think traits are finally stable enough to start writing
documentation for. I'm going to submit another PR to remove some of the
experimental warnings the compiler has for traits, and with it add
documentation for traits as well. This wouldn't stabilize all trait
features (e.g. associated types are still unimplemented), but users will
now be able to use basic traits with functions without warnings. Any
unimplemented trait items (associated types again) will not be included
in the documentation.
# PR Checklist\*
- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
---------
Co-authored-by: kevaundray <[email protected]>
Aim
Referencing a trait method via the trait name, rather than a struct name. E.g.
Default::default()
instead ofMyStruct::default()
.Expected Behavior
Identical behavior to
MyStruct::default()
except with the impl being selected via type inference rather than the struct name.Bug
Compiler panic that Default::default() does not have a
FuncMeta
stored in the NodeInterner.To Reproduce
Installation Method
None
Nargo Version
No response
Additional Context
No response
Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: