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

Remove and replace misleading Time.wall_to_nanos #1967

Merged
merged 1 commit into from
Jun 21, 2017
Merged

Conversation

SeanTAllen
Copy link
Member

Based on its description and name, one would be reasonable in expecting
Time.wall_to_nanos to take a wall clock time and convert it the number
of nanoseconds since the "start of time". That isn't however what it
does. It was getting an absolute time to fire a timer setup in
Timer.abs.

This PR correct this problem by moving the functionality that previously
existed in wall_to_nanos into Timer as a private method and adds a
function to Nanos to convert from a wall clock time to nanoseconds.

@SeanTAllen
Copy link
Member Author

I believe this breaking change should count as a principle of least surprise bug fix.

Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

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

Your reasoning sounds right to me as well, but I'd like some other(s) to agree before merging, since it is a breaking change, and I'm not totally confident that I'm not missing something.

@SeanTAllen
Copy link
Member Author

Serialization tests for this failed across the board. I believe its the work that @Praetonus has been doing. Its not clear to me why they failed.

@SeanTAllen
Copy link
Member Author

SeanTAllen commented Jun 15, 2017

In particular: CodegenTest.CustomSerialization fails.

It fails for me locally a well but master does not. I'm totally stumped why that would happen.

@Praetonus
Copy link
Member

Praetonus commented Jun 15, 2017

The error is

Error:
/home/travis/build/ponylang/ponyc/packages/time/timer.pony:59:39: receiver type is not a subtype of target type
    _expiration = _abs_expiration_time(expiration)
                                      ^
    Info:
    /home/travis/build/ponylang/ponyc/packages/time/timer.pony:59:19: receiver type: Timer tag
        _expiration = _abs_expiration_time(expiration)
                      ^
    /home/travis/build/ponylang/ponyc/packages/time/timer.pony:117:3: target type: Timer box
      fun _abs_expiration_time(wall: (I64, I64)): U64 =>
      ^
    /home/travis/build/ponylang/ponyc/packages/time/timer.pony:59:19: Timer tag is not a subtype of Timer box: tag is not a subcap of box
        _expiration = _abs_expiration_time(expiration)

It looks like not every field of Timer is initialised when calling _abs_expiration_time in a constructor, resulting in the object having a capability of tag.

I think we should add a more detailed error for those cases, something like this would be possible if all fields were intialised before calling the function.

@SeanTAllen
Copy link
Member Author

@Praetonus why does that cause custom serialization to fail?

Based on its description and name, one would be reasonable in expecting
`Time.wall_to_nanos` to take a wall clock time and convert it the number
of nanoseconds since the "start of time". That isn't however what it
does. It was getting an absolute time to fire a timer setup in
Timer.abs.

This PR correct this problem by moving the functionality that previously
existed in `wall_to_nanos` into Timer as a private method and adds a
function to `Nanos` to convert from a wall clock time to nanoseconds.
@SeanTAllen
Copy link
Member Author

Pushing fix.

@jemc
Copy link
Member

jemc commented Jun 15, 2017

I agree with @Praetonus that we can do better with that error message.

It should be relatively to provide that extra information, because since the refer pass was added, we are setting the AST_FLAG_INCOMPLETE flag on the TK_THIS node to indicate that not all fields are initialized yet.

@SeanTAllen SeanTAllen merged commit 9b85180 into master Jun 21, 2017
@SeanTAllen SeanTAllen deleted the wall_to_nanos branch June 21, 2017 19:35
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.

3 participants