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: add compiler error for using Result with init #1024

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

agostbiro
Copy link
Contributor

As reported in #926, currently an #[init] method that returns a Result, but misses a #[handle_result] annotation compiles successfully, but causes problems at runtime.

This PR fixes that, so writing

#[init]
pub fn new() -> Result<Self, &'static str> { }

Now fails to compile with the

Serializing Result<T, E> has been deprecated. Consider marking your method with #[handle_result]...

message, but writing

#[init]
#[handle_result]
pub fn new() -> Result<Self, &'static str> { }

compiles successfully as before.

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

@agostbiro Thanks for the contribution! This looks good and has the necessary test checking for it, so I am ready to merge it once CI is green.

@frol frol merged commit 7634a53 into near:master Jun 19, 2023
13 checks passed
@agostbiro agostbiro deleted the 926-compiler-error-for-result-with-init branch June 20, 2023 07:04
agostbiro added a commit to agostbiro/near-sdk-rs that referenced this pull request Jun 20, 2023
A new test case was added in near#1024, this had to be moved and updated
to reflect the changes in 79b5bc7
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