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

Incorrect error message when accessing method from returned value #71

Open
pigpigyyy opened this issue Jan 2, 2025 · 0 comments
Open
Assignees
Labels
P1 长期重要

Comments

@pigpigyyy
Copy link
Contributor

Description

When calling a method on a returned value, the error message is incorrect.

Reproduction

type A: struct {
}

func NewA() => A {
  return A{}
}

func A.f() {
}

func main {
  NewA().f()
}

The current error is:

f is not in method set of A

However, in Go, we would expect the following error:

cannot call pointer method on NewA()
cannot take the address of NewA()

Expected behavior

The error message should be similar to Go’s message, indicating that methods on a pointer receiver cannot be called directly on a returned value. But the current error message could lead to confusion.

Environment

wa-lang version: v0.19.0

@chai2010 chai2010 self-assigned this Jan 2, 2025
@chai2010 chai2010 added the P1 长期重要 label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 长期重要
Projects
None yet
Development

No branches or pull requests

2 participants