Repository navigation
[pigeon] ObjC generator doesn't handle nullable enum fields correctly #118733
Description
Activity
- addedplatform-iosiOS applications specificallyiOS applications specificallypackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.p: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Jan 18, 2023 (Supporting this isn't that important in practice, since "nullable enum" is kind of a weird concept and thus unlikely to come up much in practice, and it's easy for clients to work around by making it non-nullable with an explicit null state, but we should at least be erroring out during generator validation instead of generating incorrect code.)
- Generating a wrapper class in the case of a nullable enum, that would behave sort of like C++'s
std::optional.
Since we don't have templating in ObjC, I think we'd need to generate a class per nullable enum. The class would be trivial though, something like:
@interface NullableMyEnumType : NSObject @property(nonatomic, assign) MyEnumType value; @endThe
@implementationwould be empty since property synthesis would take care of the rest.- Generating a wrapper class in the case of a nullable enum, that would behave sort of like C++'s
- addedteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
on Jul 8, 2023 - added a commit that references this issue
on Aug 28, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Sep 11, 2023 - added a commit that references this issue
on Jun 10, 2026 - added a commit that references this issue
on Jun 19, 2026
The
AllNullableTypesnullable enum field, which isgenerates
That can't express a null value. Currently what happens is you get whatever
0maps to in the enum, which is wrong.IIRC @gaaclarke and I have discussed this in the past; using NSNumber like we do for other numeric types means clients have to cast, which isn't great. Options I can see include:
std::optional.