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

Forbid comparing null with non-optional type #571

Merged
merged 7 commits into from
Jul 19, 2024

Conversation

Gusarich
Copy link
Member

@Gusarich Gusarich commented Jul 14, 2024

Closes #570

  • I have updated CHANGELOG.md
  • I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@Gusarich Gusarich added this to the v1.4.1 milestone Jul 14, 2024
@Gusarich
Copy link
Member Author

Gusarich commented Jul 14, 2024

Seems that __tact_load_address_opt is being used for optional addresses even though the type of the field might be not nullable

@anton-trunov anton-trunov self-assigned this Jul 14, 2024
@Gusarich
Copy link
Member Author

It seems that currently Address type can be null by default even without marking it with ? sign and simply refers to addr_none:

if (msg.response_destination != null) { // Cashback

I believe that this is wrong behavior and null should only be allowed in nullable types marked with ?, e.g. Address?.

We should probably move this one to 1.5.0 because resolving this will require adding or changing some functionality related to work with addresses.

@anton-trunov
Copy link
Member

We should probably move this one to 1.5.0 because resolving this will require adding or changing some functionality related to work with addresses.

It's ok to change things if this fixes a bug

@Gusarich
Copy link
Member Author

Gusarich commented Jul 19, 2024

Actually, after investigating this issue a bit further I understood that there are no bugs in optional addresses and __tact_load_address_opt is only used when the address is optional.

The reason for test fail is that they were originally wrong - response_destination on the line I mentioned above is always not null but there is still a comparison.

So to finish with this PR and #570 we can just fix the SampleJetton test case, and get back to #515 (comment) in the next release.

@anton-trunov
Copy link
Member

So to finish with this PR and #570 we can just fix the SampleJetton test case, and get back to #515 (comment) in the next release.

let's go for it

@Gusarich Gusarich force-pushed the struct-null-comparison branch from 42a7090 to 2e83483 Compare July 19, 2024 07:35
@Gusarich Gusarich requested a review from anton-trunov July 19, 2024 07:41
@anton-trunov
Copy link
Member

@Gusarich I fixed some edge cases with void types and refactored the implementation a bit, please have a look. Maybe you can break it or add new test cases

@Gusarich
Copy link
Member Author

@Gusarich I fixed some edge cases with void types and refactored the implementation a bit, please have a look. Maybe you can break it or add new test cases

Looks good!

@anton-trunov anton-trunov merged commit 72665ba into tact-lang:main Jul 19, 2024
3 checks passed
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.

Checking for null a struct throw FunC compilation error
2 participants