diff --git a/src/Type.h b/src/Type.h index b9514739bd..f29180fb0b 100644 --- a/src/Type.h +++ b/src/Type.h @@ -515,6 +515,20 @@ public: */ const std::optional& GetCaptures() const { return captures; } + /** + * Returns whether it's acceptable for a "return" inside the function + * to not have an expression (even though the function has a return + * type). Used internally for lambdas built for "when" statements. + */ + bool ExpressionlessReturnOkay() const { return expressionless_return_okay; } + + /** + * Sets whether it's acceptable for a "return" inside the function + * to not have an expression (even though the function has a return + * type). Used internally for lambdas built for "when" statements. + */ + void SetExpressionlessReturnOkay(bool is_ok) { expressionless_return_okay = is_ok; } + protected: friend FuncTypePtr make_intrusive(); @@ -526,6 +540,8 @@ protected: std::vector prototypes; std::optional captures; // if nil then no captures specified + // Used for internal lambdas built for "when" statements: + bool expressionless_return_okay = false; }; class TypeType final : public Type