diff options
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index 71231b9e5..abfe7afa0 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -502,6 +502,17 @@ namespace Slang // TODO: we should handle the special case of `{0}` as an initializer // for arbitrary `struct` types here. + // If this initializer list has a more specific type than just + // InitializerListType (i.e. it's already undergone a coercion) we + // should ensure that we're allowed to coerce from that type to our + // desired type. + // If this isn't prohibited, then we can proceed to try and coerce from + // the initializer list itself; assuming that coercion is closed under + // composition this shouldn't fail. + if(!as<InitializerListType>(fromInitializerListExpr->type) && + !canCoerce(toType, fromInitializerListExpr->type, nullptr)) + return _failedCoercion(toType, outToExpr, fromInitializerListExpr); + if(!_readAggregateValueFromInitializerList(toType, outToExpr, fromInitializerListExpr, argIndex)) return false; |
