Skip to content

Binary operations on Byte enums throw exceptions in PS 5+ #2310

@gpduck

Description

@gpduck

Steps to reproduce

[System.Security.AccessControl.AceFlags]::ObjectInherit -bor [System.Security.AccessControl.AceFlags]::ContainerInherit

Expected behavior

3

Actual behavior

On v5 i get

Specified cast is not valid.
At line:1 char:1
+ [System.Security.AccessControl.AceFlags]::ObjectInherit -bor [System. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], InvalidCastException
    + FullyQualifiedErrorId : System.InvalidCastException

on v6 alpha 10 I'm getting

Unable to cast object of type 'System.Int32' to type 'System.Security.AccessControl.AceFlags'.
At line:1 char:1
+ [System.Security.AccessControl.AceFlags]::ObjectInherit -bor [System. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], InvalidCastException
    + FullyQualifiedErrorId : System.InvalidCastException

Environment data

This works on my v4/Server 2012 R2, but not anywhere I've installed v5 or v6.

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.34209
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productWG-Enginecore PowerShell engine, interpreter, and runtimeWG-Languageparser, language semantics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions