summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-stdlib.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-28 16:57:53 -0700
committerGitHub <noreply@github.com>2024-03-28 16:57:53 -0700
commit75afa659e9a16589638083a1fcf9e879225619cd (patch)
tree1462b68a47f2f1b4856e298185ad24145a4acc83 /source/slang/slang-stdlib.cpp
parent56928794d0800824dc91e150cb345b5fec24d930 (diff)
Fix type union logic in generic type inference. (#3852)
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
-rw-r--r--source/slang/slang-stdlib.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index 2bc24d8ec..3c8b48e00 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -222,7 +222,12 @@ namespace Slang
{
return kConversionCost_IntegerToFloatConversion;
}
-
+ else if (toInfo.conversionKind == kBaseTypeConversionKind_Float
+ && toInfo.conversionRank >= kBaseTypeConversionRank_Int16
+ && fromInfo.conversionRank >= kBaseTypeConversionRank_Int8)
+ {
+ return kConversionCost_IntegerToHalfConversion;
+ }
// All other cases are considered as "general" conversions,
// where we don't consider any one conversion better than
// any others.