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

Improve message sending #38

Merged
merged 9 commits into from
Oct 3, 2021
Merged

Improve message sending #38

merged 9 commits into from
Oct 3, 2021

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Sep 9, 2021

@madsmtm madsmtm added the enhancement New feature or request label Sep 9, 2021
@madsmtm madsmtm mentioned this pull request Sep 9, 2021
80 tasks
Also cuts down on the hoops we have to jump through from msg_send to reach the actual message sending
In Objective-C, having a null pointer receiver is valid, but with `msg_send!` it would be converted into a reference, which is undefined behavior. The reference was converted into a pointer immediately after, but it is still UB. There might also be a mutable reference somewhere else in the program, which would now be aliased.

With this, we can now stop de-referencing the receiver of msg_send!, and still have Id work ergonomically. However, null pointer receivers are still discouraged because of all the other issues they cause!

This change additionally allows sending messages to NonNull<T>, Option<&[mut] T> and Option<NonNull<T>>.
This makes the syntax match Rust expectations a bit closer IMO
Rustfmt can't do this for us
We actually don't want to encourage sending messages to nil objects, since that is only supported for selectors that return pointers
@madsmtm madsmtm merged commit bf75ec3 into master Oct 3, 2021
@madsmtm madsmtm deleted the better-message branch October 3, 2021 21:05
@madsmtm madsmtm added this to the objc2 v0.3 milestone Apr 2, 2022
@madsmtm madsmtm added the I-unsound A soundness hole label Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request I-unsound A soundness hole
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant