You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[pigeon] C++ generator makes uncompilable code for returning a list #105057
which doesn't work because ErrorOr<T> has a const T& rhs constructor that calls T(rhs), which is a deleted copy constructor for std::unique_ptr.
I'm confused about how this new variant of ErrorOr is intended to work now that I'm looking at it in actual use. v is a variant whose types include a T and a std::unique_ptr<T>, which in this case would be a nested double unique_ptr which seems unlikely to be the intent. @azchohfi what was the intended behavior here?
I'm sorry, but I didn't understand what you meant by nested double unique_ptr.
Why is the generated code an issue? I'm trying to understand the scenario here.
The only things not being passed by reference are bool, int64_t and double. Everything else is by reference.
I tried not to use unique_ptr for everything, but a variant is not permitted to hold references, neither is std::optional.
It sounds like the intent was that the generated return type in my case should have been ErrorOr<EncodableList> rather than ErrorOr<unique_ptr<EncodableList>> then. I'll take a look soon to see what went wrong (and get more tests spun up to cover return types).
The issue is that once T for ErrorOr<T> is itself a unique_ptr, as happened for me, things fall apart.
Hm, the more I look at ErrorOr the more confused I am. I missed that MakeWithUniquePtr returns a different type than the type it's called with. And there doesn't appear to ever be a way to use the unique_ptr variant flavor of v given the implementation of get?
It looks like the intent of v was that it could have a copy or a unique ptr and either would work as a value, but that's not actually what the implementation does. I'll try adjusting it to fit that approach and see how it works.
I think I have a workable version of this using a move-based alternate constructor instead of a unique_ptr version. (I'm still working through some unrelated issues to get and end-to-end test going.)
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 -v and a minimal reproduction of the issue.
Activity
azchohfi commentedon May 31, 2022
This is how I tested this on the video player:
std::unique_ptr<TextureMessage> textureMessage = std::make_unique<TextureMessage>(); textureMessage->set_texture_id(textureId); return ErrorOr<TextureMessage>::MakeWithUniquePtr(std::move(textureMessage));azchohfi commentedon May 31, 2022
I'm sorry, but I didn't understand what you meant by nested double unique_ptr.
Why is the generated code an issue? I'm trying to understand the scenario here.
The only things not being passed by reference are bool, int64_t and double. Everything else is by reference.
I tried not to use unique_ptr for everything, but a variant is not permitted to hold references, neither is std::optional.
stuartmorgan-g commentedon May 31, 2022
It sounds like the intent was that the generated return type in my case should have been
ErrorOr<EncodableList>rather thanErrorOr<unique_ptr<EncodableList>>then. I'll take a look soon to see what went wrong (and get more tests spun up to cover return types).The issue is that once
TforErrorOr<T>is itself aunique_ptr, as happened for me, things fall apart.stuartmorgan-g commentedon Jun 1, 2022
Hm, the more I look at
ErrorOrthe more confused I am. I missed thatMakeWithUniquePtrreturns a different type than the type it's called with. And there doesn't appear to ever be a way to use theunique_ptrvariant flavor ofvgiven the implementation ofget?It looks like the intent of
vwas that it could have a copy or a unique ptr and either would work as a value, but that's not actually what the implementation does. I'll try adjusting it to fit that approach and see how it works.stuartmorgan-g commentedon Jun 1, 2022
I think I have a workable version of this using a move-based alternate constructor instead of a
unique_ptrversion. (I'm still working through some unrelated issues to get and end-to-end test going.)github-actions commentedon Aug 4, 2022
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.