serum-errors / go-serum-analyzer

Other
7 stars 2 forks source link

Resolve type assertion #3

Closed TripleDogDare closed 1 year ago

TripleDogDare commented 1 year ago

This gives an error instead of a panic for the demo code base in #2. (#5 go1.18+ fix seems to have resolved the panic as well)

Now it returns a bunch of errors that seem much more reasonable, if not any more functional. There's a good chance that the codes from the old identity could be assigned to the new identity and just ignore the type assertion but I'm not really sure how to do that.

$ go-serum-analyzer -strict ./...
/home/cjb/repos/misc/go-demo-app-with-serum/cli/cli.go:107:1: function "Do" is exported, but does not declare any error codes
/home/cjb/repos/misc/go-demo-app-with-serum/jobbers/terror/terror.go:23:6: unsupported: tracking error codes across type assertions
/home/cjb/repos/misc/go-demo-app-with-serum/jobbers/terror/terror.go:21:1: function "InducePanic" has a mismatch of declared and actual error codes: unused codes: [jobber-error-natch]
TripleDogDare commented 1 year ago

I think I got it to do the right thing! I still have no idea what the ast.TypeAssertExpr.X refers to so it's just a guess. However, it appears to do the right thing against the demo code branch.

TripleDogDare commented 1 year ago

So this is less required now that it no longer panics. However, adding tests and better error messages for handling type assertion seems nice to have.