-
Notifications
You must be signed in to change notification settings - Fork 378
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
Annotate does not implement
preprocessing error
#1684
Comments
does not implement
preprocessing errordoes not implement
preprocessing error
This should be done but only after there is refactoring of the preprocessor as far as error handling goes. |
…terface (#2492) Related to #1684 . This is a first draft that will increment the amount of information Gno returns in the case of an struct not implementing a defined interface. ### First Case `A non defined function on interface` ```go package main type Car interface{ Run(speed int) } type Toyota struct {} func main(){ var car Car = &Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: *main.Toyota does not implement main.Car (missing method Run) [recovered]` ### Second Case `A defined function with bad type on function signature` ```go package main type Car interface{ Run(speed int) } type Toyota struct {} func (toyota *Toyota) Run(quick bool){ } func main(){ var car Car = &Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: *main.Toyota does not implement main.Car (wrong type for method Run) [recovered]` ### Third Case `A defined function with a pointer receiver but not pointer variable` ```go package main type Car interface { Run() } type Toyota struct { } func (t *Toyota) Run() { } func main() { var car Car = Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: main.Toyota does not implement main.Car (method Run has pointer receiver):` <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
…terface (gnolang#2492) Related to gnolang#1684 . This is a first draft that will increment the amount of information Gno returns in the case of an struct not implementing a defined interface. ### First Case `A non defined function on interface` ```go package main type Car interface{ Run(speed int) } type Toyota struct {} func main(){ var car Car = &Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: *main.Toyota does not implement main.Car (missing method Run) [recovered]` ### Second Case `A defined function with bad type on function signature` ```go package main type Car interface{ Run(speed int) } type Toyota struct {} func (toyota *Toyota) Run(quick bool){ } func main(){ var car Car = &Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: *main.Toyota does not implement main.Car (wrong type for method Run) [recovered]` ### Third Case `A defined function with a pointer receiver but not pointer variable` ```go package main type Car interface { Run() } type Toyota struct { } func (t *Toyota) Run() { } func main() { var car Car = Toyota{} } ``` **Before** we had something like: `panic: *main.Toyota does not implement main.Car [recovered]` **now**: `panic: main.Toyota does not implement main.Car (method Run has pointer receiver):` <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
Currently when an error is returned from the preprocessor due to an type not correctly implementing an interface, the error message is simply
x does not implement y
. This is checked by theIsImplementedBy
method intypes.go
. There should be a way for this method to return an error message that indicates the specific reason why the type doesn't implement the interface.The text was updated successfully, but these errors were encountered: