GH-710: Check that &expire_func is a function and not hook/event

This commit is contained in:
Jon Siwek 2020-08-21 15:37:59 -07:00
parent 9f802b2a4d
commit e1a39d27f3
3 changed files with 26 additions and 0 deletions

View file

@ -512,10 +512,19 @@ void Attributes::CheckAttr(Attr* a)
const auto& expire_func = a->GetExpr();
if ( expire_func->GetType()->Tag() != TYPE_FUNC )
{
Error("&expire_func attribute is not a function");
break;
}
const FuncType* e_ft = expire_func->GetType()->AsFuncType();
if ( e_ft->Flavor() != FUNC_FLAVOR_FUNCTION )
{
Error("&expire_func attribute is not a function");
break;
}
if ( e_ft->Yield()->Tag() != TYPE_INTERVAL )
{
Error("&expire_func must yield a value of type interval");