From 989847f6a9408b68e90ac242f4a19d3266054c3e Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 6 Nov 2024 16:42:14 -0800 Subject: Fix IntVal unification logic to insert type casts + buffer element lowering regression. (#5508) * Fix IntVal unification logic to insert type casts. * Fix regression. --- source/slang/slang-check-constraint.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/slang/slang-check-constraint.cpp') diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index 13e3e4be6..872d2616c 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -925,6 +925,12 @@ bool SemanticsVisitor::TryUnifyIntParam( // We want to constrain the given parameter to equal the given value. Constraint constraint; constraint.decl = paramDecl; + // If `val` is of different type than `paramDecl`, we want to insert a type cast. + if (val->getType() != paramDecl->getType()) + { + auto cast = m_astBuilder->getTypeCastIntVal(paramDecl->getType(), val); + val = cast; + } constraint.val = val; constraints.constraints.add(constraint); -- cgit v1.2.3