Powershell: A malformed type literal passed to the -is or -as operator is quietly ignored at the prompt

Created on 24 Dec 2019  路  7Comments  路  Source: PowerShell/PowerShell

Note that the problem only surfaces _at the interactive prompt_, whether or not PSReadLine is loaded.

In a _script_ / script block, an error occurs, as expected.

This is a regression from v6.2.3 / WinPS.

Steps to reproduce

Submit _at the prompt_:

'foo' -is [string 
'foo' -as [string 

Expected behavior

A statement-terminating error with message:

Missing ] at end of attribute or type literal.

Actual behavior

Both commands fail quietly, and $? even contains $true.

Environment data

PowerShell Core 7.0.0-rc.1
Issue-Bug Resolution-Fixed WG-Language

Most helpful comment

It's a bug with the concise error view. The exception is still in $Error and if you retrieve it the formatting is blank. @iSazonov if it doesn't repro with the latest build, it was probably fixed with #11415.

All 7 comments

Present in preview6 too, so something happened somewhere before that. 馃

I can not repo with latest build.

It works fine in 6.2.3 so it's definitely a regression 7.

Works well in 7.0 Preview1/Preview4.

It's a bug with the concise error view. The exception is still in $Error and if you retrieve it the formatting is blank. @iSazonov if it doesn't repro with the latest build, it was probably fixed with #11415.

@mklement0 Can you confirm with nightly build that the issue was fixed?

Thanks for diagnosing, @SeeminglyScience.

Indeed, @iSazonov, the problem has been fixed in the latest daily build.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abock picture abock  路  3Comments

andschwa picture andschwa  路  3Comments

aragula12 picture aragula12  路  3Comments

JohnLBevan picture JohnLBevan  路  3Comments

manofspirit picture manofspirit  路  3Comments