Skip to content

Incorrect error message when accessing method from returned value #71

@pigpigyyy

Description

@pigpigyyy

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

Metadata

Metadata

Assignees

Labels

P1长期重要

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions