option for internal use to mark a function type as allowing non-expression returns

This commit is contained in:
Vern Paxson 2022-01-07 11:50:40 -08:00
parent 6cb5ea6835
commit e22d279fdf

View file

@ -515,6 +515,20 @@ public:
*/ */
const std::optional<CaptureList>& GetCaptures() const { return captures; } const std::optional<CaptureList>& 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: protected:
friend FuncTypePtr make_intrusive<FuncType>(); friend FuncTypePtr make_intrusive<FuncType>();
@ -526,6 +540,8 @@ protected:
std::vector<Prototype> prototypes; std::vector<Prototype> prototypes;
std::optional<CaptureList> captures; // if nil then no captures specified std::optional<CaptureList> 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 class TypeType final : public Type