From c3c1b56ae693ed23804544e929a3447bc921edf6 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 2 Jun 2023 15:31:03 -0700 Subject: Fix generic param inference through TypeCastIntVal. (#2916) --- source/slang/slang-check-constraint.cpp | 4 ++++ source/slang/slang-mangle.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'source') diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index 42d01a996..f0df78c43 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -540,8 +540,12 @@ namespace Slang // Check if both are integer values in general if (auto fstInt = as(fst)) { + if (auto tc = as(fstInt)) + fstInt = as(tc->base); if (auto sndInt = as(snd)) { + if (auto tc = as(sndInt)) + sndInt = as(tc->base); auto fstParam = as(fstInt); auto sndParam = as(sndInt); diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index ef9bf4938..3b0d12da8 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -326,6 +326,24 @@ namespace Slang else if (const auto polynomialIntVal = dynamicCast(val)) { emitRaw(context, "KX"); + emit(context, (UInt)polynomialIntVal->constantTerm); + emit(context, (UInt)polynomialIntVal->terms.getCount()); + for (auto term : polynomialIntVal->terms) + { + emit(context, (UInt)term->constFactor); + emit(context, (UInt)term->paramFactors.getCount()); + for (auto factor : term->paramFactors) + { + emitVal(context, factor->param); + emit(context, (UInt)factor->power); + } + } + } + else if (const auto typecastIntVal = dynamicCast(val)) + { + emitRaw(context, "KK"); + emitVal(context, typecastIntVal->type); + emitVal(context, typecastIntVal->base); } else { -- cgit v1.2.3