-
Notifications
You must be signed in to change notification settings - Fork 570
Fix internalize case for Date into time.Time struct. #288
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
Conversation
As desired, commit 098b579 added a failing test case and it indeed failed with:
The next commit will contain a fix that should get the failing test case to pass. |
@@ -313,6 +313,13 @@ var $internalize = function(v, t, recv) { | |||
} | |||
return s; | |||
case $kindStruct: | |||
if (v !== null && v !== undefined && v.constructor === Date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably a better way to do this instead of v !== null && v !== undefined
, isn't there?
I needed it to avoid:
- TypeError: Cannot read property 'constructor' of null
- TypeError: Cannot read property 'constructor' of undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do just v
, but that matches a few more cases. I'd go with the solution you have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go with the solution you have.
Sounds good.
Please see my comment on #287. |
It's just like TestInternalizeExternalizeUndefined, but for null. It helped me uncover a bug in internalization code during development, and seems like a good idea to have it for better coverage.
Test case for #287, currently failing.
Refactor based on suggestion at #287 (comment). Panic on null or undefined values instead of Date, no support for *time.Time. Remove unneeded declaration. The same variable is already declared in parent scope.
I've resolved that. What else does this PR need to be merged? |
LGTM |
Fix internalize case for Date into time.Time struct.
Don't merge, this PR is a WIP (more commits to be pushed) and in need of review.Ready for review.Add a failing test case, then fix #287.