RFC: Add a @mustuse function attribute#83
RFC: Add a @mustuse function attribute#83CompeyDev wants to merge 3 commits intoluau-lang:masterfrom
@mustuse function attribute#83Conversation
This RFC proposes a `@mustuse` attribute, which may be applied to a function, enforcing the usage of a function's return value.
|
I know it's used in several languages, but to me "mustuse" is sort of confusing - it sounds like you have to use the function. In C++ there is the gcc attribute warn_unused_result and the standard nodiscard (don't discard the return value or you get a warning), both of which seem better to me |
I would also prefer |
|
I'd like it if there was a 'reason' argument supported for this attribute, as it may not be obvious at a glance why a value must be used. Also, this seems like it'd need a presence in the type system. That's not currently implemented, so this RFC is somewhat hiding a much more complicated proposal behind it. I suggest you (or someone else) write an RFC for attributes to exist in the type system. |
I was looking to do that as an extension to this RFC once it is merged. |
This RFC proposes a
@mustuseattribute, which may be applied to a function, enforcing the usage of a function's return value.Rendered.