Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Non-predefined preference variables aren't type-/value-constrained. #3644

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Related: #3483

Preference variable $ErrorView, despite only supporting 2 values - NormalView and CategorizedView - is defined as a [string] and therefore quietly accepts any value (and falls back to NormalView). [This has been fixed]

It should probably be an enumeration type, as similar preference variables are (e.g., $ErrorActionPreference -is [enum] returns $true)

Similarly, the fact that some preference variables aren't predefined altogether allows their creation with inappropriate types.

Note that this problem exists separately from the fact that creating preference variables in child scopes never enforces their intended types, even if they're appropriately type-constrained in the global scope.

Steps to reproduce

$LogCommandHealthEvent = 'I should be a Boolean'

Expected behavior

(Statement-terminating) errors complaining about the inappropriate values.

Actual behavior

The invalid values are quietly accepted.

Currently, the following preference variables aren't predefined:

  • [bool]: LogCommandHealthEvent LogCommandLifecycleEvent LogEngineHealthEvent LogEngineLifecycleEvent LogProviderLifecycleEvent LogProviderHealthEvent

  • [int]: MaximumAliasCount, MaximumDriveCount, MaximumErrorCount, MaximumFunctionCount, MaximumVariableCount - these are predefined in Windows PowerShell v5.1, however.

  • enum [PSModuleAutoLoadingPreference]: PSModuleAutoLoadingPreference

  • [string]: OFS, but given that it is conceptually [string] and that any value can be converted to a string, that is less of an issue.

  • Others?

Environment data

PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Languageparser, language semanticsparser, language semantics

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.