Repository navigation
fix(stl/variant): emplace<T>() returns T& not T* - #2783
Conversation
`fl::variant::emplace<T>(Args&&...)` is declared to return `T&` but the body was `return ptr<T>();` (which returns `T*`). The error was only flagged by the compiler when emplace got actually instantiated — which happened first while attempting #2773 item 1.4 (`EspIO` variant-based driver selection): src/fl/stl/variant.h:102:22: error: invalid initialization of non-const reference of type 'fl::enable_if<true, fl::UartEsp32&>::type' {aka 'fl::UartEsp32&'} from an rvalue of type 'fl::UartEsp32*' One-character fix: dereference the pointer in the return statement so the returned type matches the signature. No existing callers were affected because emplace had zero in-tree users — host tests still pass (`bash test variant --cpp` → 1/1). Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request fixes a bug in the Changesvariant::emplace Return Type Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~1 minute Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
fl::variant::emplace<T>(Args&&...)is declared to returnT&but the body wasreturn ptr<T>();(whereptr<T>()returnsT*). The mismatch was latent because emplace had no in-tree users — the error surfaced the moment something actually called it (in my case, while attempting #2773 item 1.4):One-character fix: dereference the pointer.
Tests
bash test variant --cpp— 1/1 passes🤖 Generated with Claude Code
Summary by CodeRabbit