-
Notifications
You must be signed in to change notification settings - Fork 18k
internal/reflectlite: Implements erroneously reports that map types do not implement interfaces #34486
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
Comments
This is fixed in master, after https://go-review.googlesource.com/c/go/+/191198 |
Closing based on @cuonglm's reply. @proglottis, please let us know if this still isn't working for you using |
Thought I'd have a go with gotip, and it now panics. This might be fine if maps aren't supported, but the message is not correct as this type does implement error.
I wanted to exclude the possibility that there's something going on in the 3rd party library, and also add a compile time |
Hmm, somehow, |
Yes, this is a bug in |
Change https://golang.org/cl/197179 mentions this issue: |
CC @bradfitz, who has also made some (probably unrelated) changes in |
One thing that I noticed while looking at reflectlite is that we forgot to update it (we updated reflect) in https://golang.org/cl//191198 which likely causes mismatches of struct definitions between runtime and reflectlite. Especially the map type is now larger: go/src/internal/reflectlite/type.go Line 245 in 0f7b4e7
Line 363 in 9c0e56b
While at it we should add tests (to avoid misalignment and breakage of reflectlite) and update the comments to reference reflectlite for updates too. Im happy work on a fix tomorrow evening UTC if no one jumps on realigning the definitions earlier. |
Change https://golang.org/cl/197558 mentions this issue: |
Change https://golang.org/cl/197559 mentions this issue: |
@cuonglm got to it before I could finish writing tests locally and verify this fixes issues seen. Can we also add tests to https://golang.org/cl/197559 to prevent this from happening again? |
Sure, but how can we test it generally? Or you mean we just test for |
At the very least, the regression test from https://golang.org/cl/197179 should be added. Would it also be possible to, say, add a test somewhere that uses |
I don' know anyway, since when all of them are un-exported IIRC. |
I can think of a few possibilities to consider:
|
I started working on a test the other day until I realized how gross this all was (and that I was distracted from my primary task). But my conclusion was that (3) would be the least gross/invasive/objectionable. |
Agreed that (3) is the least invasive. I suspect I would find (4) a lot less “gross”. (But “gross” and “objectionable” are both subjective, so I'll leave that up to the folks who are actually maintaining these packages day-to-day.) |
While my personal preference would be many small packages to minimize repetition (option (4)), historically I've seen enough resistance to such refactoring that I now try to avoid it in Go projects. |
Change https://golang.org/cl/199280 mentions this issue: |
Updates #34486 Change-Id: Iec9a5d120013aaa287eccf2999b3f2b831be070e Reviewed-on: https://go-review.googlesource.com/c/go/+/197558 Reviewed-by: Ian Lance Taylor <[email protected]>
Add test to check that struct type in reflectlite is mirror of reflect. Note that the test does not check the field types, only check for number of fields and field name are the same. Updates #34486 Change-Id: Id5f9b26d35faec97863dd1fe7e5eab37d4913181 Reviewed-on: https://go-review.googlesource.com/c/go/+/199280 Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to check if an error was of type schema.MultiError.
https://play.golang.org/p/eAMul1kgxXJ
What did you expect to see?
Preferably it would populate my
errMulti := schema.MultiError{}
variable so I can inspect the contents for better error handling.What did you see instead?
A runtime error:
The text was updated successfully, but these errors were encountered: