8000 Fix issue where yield_to can return too early by jamie-pate · Pull Request #455 · bitwes/Gut · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix issue where yield_to can return too early #455

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

Merged
merged 1 commit into from
Feb 23, 2023

Conversation

jamie-pate
Copy link

If the signal emits the value 'false' as the first argument this will assume that it's the bound 'false' value which signifies a timeout.. This is because bound arguments appear at the end of the callback parameter list, not a the beginning.

Instead of using true/false, this change binds a sentinel. We can definitively know whether the callback came from the bound signal or a timeout.

See also #327

@jamie-pate jamie-pate force-pushed the feat_yield_from_obj_fix branch 2 times, most recently from d54a13d to ea96ad1 Compare January 20, 2023 21:36
Copy link
Owner
@bitwes bitwes left a comment

Choose a reason for hiding this comment

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

Good find! I had a bit of trouble following what the issue was, but the test helped. You have some syntax issues and one future proofing issue. Address those and I'll take another look.

P.S. Try running the tests before opening a PR ;). If you are having any issues getting setup to the GUT test suite, let me know. It's all a bit gross using the tool to test the tool.

Thanks for the PR

@@ -61,6 +61,7 @@ const LOG_LEVEL_ALL_ASSERTS = 2
const WAITING_MESSAGE = '/# waiting #/'
const PAUSE_MESSAGE = '/# Pausing. Press continue button...#/'
const COMPLETED = 'completed'
const YIELD_FROM_OBJ = {}
Copy link
Owner

Choose a reason for hiding this comment

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

Since 4.0 compares dictionaries by value this should be something else so the bug does not show back up when being ported to 4.0. A Node instance would work if we make this a var instead...which is fine with me. Keep the all-caps so we know it should be constant.

var YIELD_FROM_OBJ = Node.new()

Copy link
Author

Choose a reason for hiding this comment

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

I guess we don't care about leaking the node since gut is a singleton?

Copy link
Author
8000

Choose a reason for hiding this comment

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

I figured out you can use a class as a sentinel and then it can be used in places that require a constant expression. I'm not sure there is a better way to create a const sentinal with a unique identity

If the signal emits the value 'false' as the first argument this will
assume that it's the bound 'false' value which signifies a timeout..
This is because bound arguments appear at the end of the callback
parameter list, not a the beginning.

Instead of using true/false, this change binds a sentinel. We can
definitively know whether the callback came from the bound signal or a
timeout.

See also bitwes#327
@jamie-pate jamie-pate force-pushed the feat_yield_from_obj_fix branch from 39eb8b1 to 882e625 Compare January 21, 2023 20:11
@bitwes
Copy link
Owner
bitwes commented Feb 23, 2023

This looks good. Thanks for the contribution!

@bitwes bitwes merged commit d3c1fcc into bitwes:master Feb 23, 2023
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
0