Skip to content

Commit

Permalink
Fix generating OutputType when running in Constrained Language Mode (
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeminglyScience committed May 6, 2024
1 parent 0fee363 commit 467538f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/System.Management.Automation/engine/parser/Compiler.cs
Expand Up @@ -1565,7 +1565,15 @@ private static Attribute NewOutputTypeAttribute(AttributeAst ast)

if (args[0] is Type)
{
result = new OutputTypeAttribute(LanguagePrimitives.ConvertTo<Type[]>(args));
// We avoid `ConvertTo<Type[]>(args)` here as CLM would throw due to `Type[]`
// being a "non-core" type. NOTE: This doesn't apply to `string[]`.
Type[] types = new Type[args.Length];
for (int i = 0; i < args.Length; i++)
{
types[i] = LanguagePrimitives.ConvertTo<Type>(args[i]);
}

result = new OutputTypeAttribute(types);
}
else
{
Expand Down

0 comments on commit 467538f

Please sign in to comment.