diff options
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 66c2f9796..f4c8cd847 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -4065,6 +4065,13 @@ Expr* SemanticsExprVisitor::visitIsTypeExpr(IsTypeExpr* expr) expr->type = m_astBuilder->getBoolType(); expr->value = originalVal; + // Check if the right-hand side type is an interface type + if (isInterfaceType(expr->typeExpr.type)) + { + getSink()->diagnose(expr, Diagnostics::isAsOperatorCannotUseInterfaceAsRHS); + return expr; + } + auto valueType = expr->value->type.type; if (auto typeType = as<TypeType>(valueType)) valueType = typeType->getType(); @@ -4103,6 +4110,15 @@ Expr* SemanticsExprVisitor::visitAsTypeExpr(AsTypeExpr* expr) TypeExp typeExpr; typeExpr.exp = expr->typeExpr; typeExpr = CheckProperType(typeExpr); + + // Check if the right-hand side type is an interface type + if (isInterfaceType(typeExpr.type)) + { + getSink()->diagnose(expr, Diagnostics::isAsOperatorCannotUseInterfaceAsRHS); + expr->type = m_astBuilder->getErrorType(); + return expr; + } + expr->value = CheckTerm(expr->value); auto optType = m_astBuilder->getOptionalType(typeExpr.type); expr->type = optType; |
