File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -547,12 +547,29 @@ private IEnumerable<DiagnosticRecord> FindOperatorViolations(TokenOperations tok
547547 else if ( tokenHasBinaryFlag // binary flag is set but not unary
548548 // include other (non-expression) binary operators
549549 || TokenTraits . HasTrait ( tokenNode . Value . Kind , TokenFlags . AssignmentOperator )
550+ || tokenNode . Value . Kind == TokenKind . Redirection
550551 || tokenNode . Value . Kind == TokenKind . AndAnd
551552 || tokenNode . Value . Kind == TokenKind . OrOr
553+ #if ! ( NET452 || PSV6 ) // include both parts of ternary operator but only for PS7+
554+ || TokenTraits . HasTrait ( tokenNode . Value . Kind , TokenFlags . TernaryOperator )
555+ || tokenNode . Value . Kind == TokenKind . Colon
556+ #endif
552557 ) {
553558 checkLeftSide = true ;
554559 checkRightSide = true ;
555560 }
561+ // Treat call and dot source operators as unary with operand on right.
562+ else if ( ( tokenNode . Value . Kind == TokenKind . Dot || tokenNode . Value . Kind == TokenKind . Ampersand )
563+ && tokenOperations . GetAstPosition ( tokenNode . Value ) is CommandAst )
564+ {
565+ checkRightSide = true ;
566+ }
567+ #if ! ( NET452 ) // Treat background operator as unary with operand on left (only exists in PS6+)
568+ else if ( tokenNode . Value . Kind = = TokenKind . Ampersand )
569+ {
570+ checkLeftSide = true ;
571+ }
572+ #endif
556573 else // Token is not an operator
557574 {
558575 continue ;
You can’t perform that action at this time.
0 commit comments