Commit Detail
Commit 64b59bc
Reset kj::Maybes with `kj::none` instead of `{}`
The capnproto pull request
https://github.com/capnproto/capnproto/pull/2014 adds another
assignment operator for Maybes. With a version of capnproto including
that PR, we get compilation errors of the form:
```
external/workerd/src/workerd/io/worker.c++:2524:15: error: use of overloaded operator '=' is ambiguous (with operand types 'kj::Maybe<InspectorChannelImpl &>' and 'void')
channel = {};
~~~~~~~ ^ ~~
bazel-out/k8-dbg/bin/external/capnp-cpp/src/kj/_virtual_includes/kj/kj/common.h:1679:17: note: candidate function
inline Maybe& operator=(decltype(nullptr)) { ptr = nullptr; return *this; }
^
bazel-out/k8-dbg/bin/external/capnp-cpp/src/kj/_virtual_includes/kj/kj/common.h:1682:17: note: candidate function
inline Maybe& operator=(T* other) { ptr = other; return *this; }
^
```
The Maybes that I fixed in this PR are all reference
types (`Maybe<T&>`), so I’m not sure what assigning `{}` would do,
since if it’s assigning a temporary, the reference will be garbage.
However, in the three cases here, we seem to be resetting the objects,
so assigning `kj::none` is correct.
Files changed
1 file changed~1 modified