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

Prohibit the use of Self in non-init functions #1005

Closed
itegulov opened this issue Jan 23, 2023 · 3 comments · Fixed by #1073
Closed

Prohibit the use of Self in non-init functions #1005

itegulov opened this issue Jan 23, 2023 · 3 comments · Fixed by #1073
Assignees

Comments

@itegulov
Copy link
Contributor

The use of Self in non-init context might be harmful as sometimes it indicates that the function was meant to be marked with #[init]. It might make sense to gradually prohibit this pattern, e.g. give a deprecation warning in 4.2 and give a compilation error in 5.0.

Originally pointed out in #972 (comment).

@uint
Copy link
Contributor

uint commented Jun 22, 2023

Once the deprecation warning is there, should we create a 5.0 milestone and attach this issue to it so that we don't forget to switch to the compilation error when it's time?

@uint
Copy link
Contributor

uint commented Jun 22, 2023

Also, should passing a Self argument still be fine? The original motivation was about using it as the return type from what I see.

@itegulov
Copy link
Contributor Author

We already have a tracking issue for 5.0: #946

Also, should passing a Self argument still be fine? The original motivation was about using it as the return type from what I see.

I personally think that all Self usage is potentially harmful in this context, but this is very opinionated

@frol frol mentioned this issue Oct 25, 2022
9 tasks
@uint uint self-assigned this Aug 18, 2023
@frol frol closed this as completed in #1073 Oct 8, 2023
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 a pull request may close this issue.

2 participants