Skip to content

Necessary updates for the new ternary operator added in PowerShell language #1314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
daxian-dbw opened this issue Aug 19, 2019 · 2 comments

Comments

@daxian-dbw
Copy link
Member

daxian-dbw commented Aug 19, 2019

The ternary operator will soon be added to the PowerShell language. Necessary updates may be needed for the PSSA:

  • New AST type TernaryExpressionAst is added. Changes are made to the visitors in PowerShell. The visitors in PSSA may need to be updated too.

/cc @rjmholt

@bergmeister
Copy link
Collaborator

Thanks for the notice.
Note: If a change is required then that means we'd need to compile conditionally against PS v7 as well (at the moment v6 and v7 both work well together).

@rjmholt
Copy link
Contributor

rjmholt commented Aug 19, 2019

This and a couple of other changes in PS 7 will add AST types. Those will add new methods to ICustomAstVisitor2 and AstVisitor2, but they won't be breaking changes like they would have been in the past since .NET Core 3.0 allows default interface implementation and we provide those.

The real issue is if new or existing rules need to know about things like ternary expressions, modulo the fact that an unmodified AST visitor will still pick up subexpressions without issue.

For example, a rule that checks integer use in floating point expressions will be fine with 1 -gt 4 ? 3.0*3 : 4.0*1, since it will still see the three subexpressions.

But in a case where you have something like a rule that does something like try to infer the result of an assignment or an expression, we might need to add support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants