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

Fix checks for key existance in objects #208

Merged
merged 11 commits into from
Apr 2, 2024

Conversation

Gusarich
Copy link
Member

@Gusarich Gusarich commented Mar 29, 2024

Closes #181 and closes #182

  • I have updated CHANGELOG.md
  • I have added unit tests to demonstrate the contribution is correctly implemented
  • I have run all the tests locally and no test failure was reported
  • I did not introduce unrelated formatting/whitespace changes in the code base
  • I did not do unrelated and/or undiscussed refactorings

It was a bug with how existance of object keys was checked.
Accessing key by doing myObject[key] also includes built-in keys like toString and valueOf and results problems afterwards. In such cases .hasOwnProperty method should be used.

UPD: Object.prototype.hasOwnProperty.call has to be used instead of .hasOwnProperty, as explained in https://stackoverflow.com/a/39283005. This also was reported by ESLint before fix.

@Gusarich Gusarich requested a review from anton-trunov March 29, 2024 08:52
@Gusarich Gusarich changed the title fix bugs with checking that key exists in an object Fix checks for key existance in objects Mar 29, 2024
src/types/stmts/case-10.tact Outdated Show resolved Hide resolved
src/generator/writers/writeExpression.ts Outdated Show resolved Hide resolved
@anton-trunov anton-trunov self-assigned this Mar 29, 2024
@anton-trunov anton-trunov added this to the v1.3.0 milestone Mar 29, 2024
@Gusarich Gusarich requested a review from anton-trunov March 29, 2024 14:08
src/types/resolveDescriptors.ts Outdated Show resolved Hide resolved
src/types/resolveStatements.ts Outdated Show resolved Hide resolved
@anton-trunov anton-trunov added the scope: errors Error reporting mechanism (src/error) label Apr 1, 2024
@Gusarich
Copy link
Member Author

Gusarich commented Apr 2, 2024

@anton-trunov done!

@Gusarich Gusarich requested a review from anton-trunov April 2, 2024 10:19
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@anton-trunov anton-trunov merged commit c1f013f into tact-lang:main Apr 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: errors Error reporting mechanism (src/error)
Projects
None yet
2 participants