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

Better handling of NULL-unspecified types #695

Open
madsmtm opened this issue Jan 10, 2025 · 0 comments
Open

Better handling of NULL-unspecified types #695

madsmtm opened this issue Jan 10, 2025 · 0 comments
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Jan 10, 2025

Certain types are "null-unspecified", that is, we don't know enough about their null-ability to make an informed decision about how to map them. Swift uses force-unwrapped optionals which fit this purpose well, example.

For safety, we currently emit these as Option<...> in return position, and for flexibility we emit them as Option<...> in argument position.

However, I'm not sure that allowing optional types in argument position is a perfectly good idea, as it might make it harder to mark a method as safe, especially if we ever want to do that automatically? CoreFoundation seems to be pretty consistent in either crashing or returning NULL if it gets a NULL argument, but I'm not sure it always does that?

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Jan 10, 2025
madsmtm added a commit that referenced this issue Jan 11, 2025
The headers are sometimes insufficient in this regard, and you're likely
to be able to cause unsoundness if passing NULL to these.

Part of #695.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant