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

MAINT: Small fixes to fail macros #1129

Merged
merged 2 commits into from
Jan 12, 2021
Merged

Conversation

hoodmane
Copy link
Member

FAIL_IF_MINUS_ONE was checking if arg != 0, which is FAIL_IF_NONZERO. I changed that to == -1 as it should be.

Also, I added parenthesis guards for the arguments, without them, the macro contains subtle bugs: for example the conditional in FAIL_IF_MINUS_ONE(1 | 0) evaluated to true even though 1 | 0 evaluates to 1 which is not equal to -1:
Before:

1 | 0 == -1    ===>    1 | (0 == -1)    ===>    1 | 0    ===>    1 (true!)

After:

(1 | 0) == -1    ===>   0 == -1    ===>    0 (false)

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @hoodmane!

@rth rth merged commit f663085 into pyodide:master Jan 12, 2021
@hoodmane hoodmane deleted the fail-macro-paren-guards branch January 12, 2021 20:03
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