From e22d279fdf0498eec6fd76879d44eb8ced9a866e Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Fri, 7 Jan 2022 11:50:40 -0800 Subject: [PATCH] option for internal use to mark a function type as allowing non-expression returns --- src/Type.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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