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

Invalid comparisons in buzzobj_cmp #103

Open
samarseneault opened this issue Mar 9, 2022 · 0 comments
Open

Invalid comparisons in buzzobj_cmp #103

samarseneault opened this issue Mar 9, 2022 · 0 comments
Assignees

Comments

@samarseneault
Copy link
Collaborator

It seems that the intention of buzzobj_cmp in src/buzz/buzztype.c is to make comparisons between certain types illegal. For example, there is code for comparisons between 2 userdata, but not for userdata and other types, so it could be reasoned userdata can only be compared between themselves. This is not the case however (for example, they can be compard with nil).

This does not cause any error at the moment, because these other comparisons are handled implicitly by logic which is executed before in the code. However, some bugs could be introduced if the order of comparisons were changed.

This is highlighted by TEST(BuzzObjCompare, IncompatibleTypes) in src/testing/unittest/buzztype_test.cpp (instructions on how to run the tests are provided in src/testing/unittest/README.md), where the comparison between nil and a userdata should cause an error, but it doesn't.

The solution for this is likely a refactor of the function.

@samarseneault samarseneault self-assigned this Mar 9, 2022
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

No branches or pull requests

1 participant