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

First pass of #67 - Let the shim functions return an error #182

Merged
merged 2 commits into from
Aug 10, 2017

Conversation

shabbyrobe
Copy link
Contributor

@shabbyrobe shabbyrobe commented Jul 17, 2017

This change is Reviewable

if b.ShimMode == Cast {
d.p.printf("\n%s = %s(%s)\n}", vname, b.FromBase(), tmp)
} else {
d.p.printf("\n%s, err = %s(%s)\n}", vname, b.FromBase(), tmp)
Copy link
Member

Choose a reason for hiding this comment

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

Here you're generating code that shadows err without checking it first.

gen/unmarshal.go Outdated
if b.ShimMode == Cast {
u.p.printf("\n%s = %s(%s)\n", b.Varname(), b.FromBase(), refname)
} else {
u.p.printf("\n%s, err = %s(%s)\n", b.Varname(), b.FromBase(), refname)
Copy link
Member

Choose a reason for hiding this comment

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

I think you've got the same err shadowing problem here.

@philhofer
Copy link
Member

Thanks for the PR.

I made a few inline comments, but overall this looks pretty good.

I wonder whether or not this should be a new directive, since msgp:shim is already pretty gross and verbose. Maybe msgp:convert or something like that.

@shabbyrobe
Copy link
Contributor Author

Thanks heaps for the comments, can't believe I missed that error thing 😳, should be fixed now.

I started out making it a separate directive but it shared so much of the same mechanics as //msgp:shim. I was also thinking that it might be possible to add support for #184 via the same "shim mode" mechanism (though I haven't really thought that through fully yet).

I'm not really fussed one way or the other. If you reckon it should be a separate directive, I'll dive back in and clean it up for you, no problem.

@shabbyrobe
Copy link
Contributor Author

Would you like me to update this to use a different directive?

@philhofer
Copy link
Member

Sorry for the slow review time. Looks Good. Thanks again for the PR.

@philhofer philhofer merged commit 701aacd into tinylib:master Aug 10, 2017
@shabbyrobe
Copy link
Contributor Author

Awesome, thanks!

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.

2 participants