summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-conversion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
-rw-r--r--source/slang/slang-check-conversion.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp
index 00625d5f4..fafefa9dd 100644
--- a/source/slang/slang-check-conversion.cpp
+++ b/source/slang/slang-check-conversion.cpp
@@ -750,6 +750,31 @@ namespace Slang
return true;
}
+ // Allow implicit conversion from sized array to unsized array when
+ // calling a function.
+ // Note: we implement the logic here instead of an implicit_conversion
+ // intrinsic in the stdlib because we only want to allow this conversion
+ // when calling a function.
+ //
+ if (site == CoercionSite::Argument)
+ {
+ if (auto fromArrayType = as<ArrayExpressionType>(fromType))
+ {
+ if (auto toArrayType = as<ArrayExpressionType>(toType))
+ {
+ if (fromArrayType->getElementType()->equals(toArrayType->getElementType())
+ && toArrayType->isUnsized())
+ {
+ if (outToExpr)
+ *outToExpr = fromExpr;
+ if (outCost)
+ *outCost = kConversionCost_SizedArrayToUnsizedArray;
+ return true;
+ }
+ }
+ }
+ }
+
// Another important case is when either the "to" or "from" type
// represents an error. In such a case we must have already
// reporeted the error, so it is better to allow the conversion