From 4d514f792fc590e28579a184be8890613d0fdf9e Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Jul 2025 23:01:55 +0000 Subject: Fix enum array indexing by adding implicit conversion support (#7815) * Initial plan * Fix enum array indexing by adding implicit conversion support Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update enum array indexing test to support GPU backends Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- source/slang/slang-check-expr.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-check-expr.cpp') diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 41c3bd510..2891c316f 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -2490,13 +2490,10 @@ Expr* SemanticsVisitor::CheckSimpleSubscriptExpr(IndexExpr* subscriptExpr, Type* { expr = CheckExpr(expr); } - auto indexExpr = subscriptExpr->indexExprs[0]; + auto& indexExpr = subscriptExpr->indexExprs[0]; - if (!isScalarIntegerType(indexExpr->type.type)) - { - getSink()->diagnose(indexExpr, Diagnostics::subscriptIndexNonInteger); - return CreateErrorExpr(subscriptExpr); - } + auto intTargetType = getMatchingIntType(indexExpr->type.type); + indexExpr = coerce(CoercionSite::Argument, intTargetType, indexExpr, getSink()); subscriptExpr->type = QualType(elementType); -- cgit v1.2.3