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

compiler,reflect: fix NumMethods for Interface type #4268

Merged
merged 2 commits into from
May 28, 2024

Conversation

frenkel26
Copy link

Fixes #4260

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me.

Can you add a test? For example, you can add this one-line change:

--- a/testdata/reflect.go
+++ b/testdata/reflect.go
@@ -456,6 +456,7 @@ func showValue(rv reflect.Value, indent string) {
        case reflect.Interface:
                println(indent + "  interface")
                println(indent+"  nil:", rv.IsNil())
+               println(indent+"  NumMethod:", rv.NumMethod())
                if !rv.IsNil() {
                        showValue(rv.Elem(), indent+"  ")
                }

And then you can run the following:

go run ./testdata/reflect.go 2> testdata/reflect.txt

And then tinygo test should pass (it doesn't for me, but it probably will pass with your fix).

@frenkel26 frenkel26 requested a review from aykevl May 26, 2024 12:05
Copy link
Member

@dgryski dgryski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the test.

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
I confirmed it matches what go produces.

@aykevl aykevl merged commit f7c0466 into tinygo-org:dev May 28, 2024
16 of 17 checks passed
@dgryski
Copy link
Member

dgryski commented May 28, 2024

I'm going to see if there are any more tests we can uncomment from reflect/all_test.go.

@dgryski
Copy link
Member

dgryski commented May 28, 2024

#4276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants