Skip to content

Commit

Permalink
Resolve problem with casts of a single argument to vector types
Browse files Browse the repository at this point in the history
  • Loading branch information
cesaref committed Nov 23, 2020
1 parent e54f6c5 commit c19e88a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/modules/soul_core/compiler/soul_ResolutionPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,15 @@ struct ResolutionPass final
}
else if (targetType.isArrayOrVector())
{
if (numArgs == 1)
{
if (auto constant = list.items.front()->getAsConstant())
if (TypeRules::canCastTo (targetType, constant->value.getType()))
return allocator.allocate<AST::Constant> (expr.context, constant->value.castToTypeExpectingSuccess (targetType));

return expr;
}

SanityCheckPass::throwErrorIfWrongNumberOfElements (expr.context, targetType, numArgs);

auto elementType = targetType.getElementType();
Expand Down

0 comments on commit c19e88a

Please sign in to comment.