tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

make go-cmp Equal succeed

Open ldemailly opened this issue 1 year ago • 3 comments

  • [x] Avoid panic in go-cmp when it tries to find an Equal method
    • This one is a bit dicey as I don't know how to make it conditionally crash/not crash (crash for people who think it works, not crash for people like go-cmp for which it's only one option)

Splitting commits from #4356

ldemailly avatar Jul 23 '24 16:07 ldemailly

'Test' is here

https://github.com/grol-io/grol/blob/v0.24.0/ast/modify_test.go#L130

panics without this fix, also

https://github.com/google/go-cmp/blob/v0.6.0/cmp/compare.go#L312-L314

in the comment hopefully makes it clear how this helps (of note, if you do have an equal method it won't be used, yet... still better than panic imo)

ldemailly avatar Jul 24 '24 00:07 ldemailly

Would it be possible to change go-cmp instead to not call MethodByName?

aykevl avatar Jul 26 '24 14:07 aykevl

I don't think go-cmp are (or should be, really) concerned with adding special case for incomplete go, so it would need to be on tinygo's side (or users of both like me)

Not sure btw that it's hard to find callers without panic

maybe something with some build tag then?

ldemailly avatar Jul 26 '24 18:07 ldemailly