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

feat: clarify error message for bounced types from which accessed a field that does not fit in 224 bytes #1111

Conversation

i582
Copy link
Contributor

@i582 i582 commented Dec 3, 2024

Previously, the following code would produce a confusing error:

message Withdraw {
    data: Int as uint128;
    amount: Int as uint128;
}

contract Fund {
    balance: Int as uint256 = 0;

    bounced(msg: bounced<Withdraw>) {
        self.balance += msg.data;
        self.balance += msg.amount; // Type bounced<"Withdraw"> does not have a field named "amount"
    }
}

Now, it gives following error:

Maximum size of the bounced message is 224 bytes, but the "amount" field of type "Withdraw" cannot fit into it due to the size of previous fields or its own size, so it cannot be accessed. Make the type of the fields before this one smaller, or reduce the type of this field so that it fits into 224 bytes

If the type specifies only one field, it will look like this:

Maximum size of the bounced message is 224 bytes, but the "amount" field of type "Withdraw" cannot fit into it because its too big, so it cannot be accessed. Reduce the type of this field so that it fits into 224 bytes

It's way too big, but since we don't have a more complex UI for errors (like in Rust), a long clear message with all the details is better than a short but not very clear message.

Issue

Closes #1021.

Checklist

  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@i582 i582 requested a review from a team as a code owner December 3, 2024 17:11
@anton-trunov anton-trunov self-assigned this Dec 4, 2024
@anton-trunov anton-trunov added this to the v1.6.0 milestone Dec 4, 2024
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.

Looks good, just some minor remarks

src/types/resolveExpression.ts Outdated Show resolved Hide resolved
src/types/resolveExpression.ts Show resolved Hide resolved
@i582 i582 requested a review from anton-trunov December 5, 2024 08:43
@anton-trunov anton-trunov merged commit ecd8738 into tact-lang:main Dec 5, 2024
15 checks passed
sansx pushed a commit to TownSquareXYZ/tact that referenced this pull request Dec 9, 2024
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.

Improve error reporting for bounced messages with missing fields
2 participants