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-decl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 1dc230dae..806912abe 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -8485,6 +8485,16 @@ bool SemanticsVisitor::isScalarIntegerType(Type* type) return isIntegerBaseType(baseType) || baseType == BaseType::Bool; } +Type* SemanticsVisitor::getMatchingIntType(Type* type) +{ + if (isScalarIntegerType(type)) + return type; + if (auto enumTypeDecl = isDeclRefTypeOf(type)) + if (enumTypeDecl.getDecl()->tagType) + return getMatchingIntType(enumTypeDecl.getDecl()->tagType); + return m_astBuilder->getIntType(); +} + bool SemanticsVisitor::isHalfType(Type* type) { auto basicType = as(type); -- cgit v1.2.3