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

Annotate does not implement preprocessing error #1684

Open
deelawn opened this issue Feb 23, 2024 · 1 comment
Open

Annotate does not implement preprocessing error #1684

deelawn opened this issue Feb 23, 2024 · 1 comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ...

Comments

@deelawn
Copy link
Contributor

deelawn commented Feb 23, 2024

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 the IsImplementedBy method in types.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.

@deelawn deelawn changed the title does not implement preprocessing error Annotate does not implement preprocessing error Feb 23, 2024
@deelawn deelawn moved this to 🌟 Wanted for Launch in 🚀 The Launch [DEPRECATED] Feb 23, 2024
@deelawn deelawn added 📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ... labels Feb 23, 2024
@petar-dambovaliev
Copy link
Contributor

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 the IsImplementedBy method in types.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.

This should be done but only after there is refactoring of the preprocessor as far as error handling goes.
All panics should be removed first and then we can make errors nicer.
Perhaps, both can be done for this issue.

@petar-dambovaliev petar-dambovaliev self-assigned this Apr 4, 2024
@petar-dambovaliev petar-dambovaliev removed their assignment Apr 11, 2024
thehowl pushed a commit that referenced this issue Jul 17, 2024
…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>
gfanton pushed a commit to gfanton/gno that referenced this issue Jul 23, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ...
Projects
Status: 🌟 Wanted for Launch
Status: Backlog
Development

No branches or pull requests

3 participants