-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
When I work on PowerShell DSC files on an ARM-based Mac, the PowerShell extension for VS Code claims that I'm in constrained language mode and warns that I can't use the Configuration keyword.
To reproduce:
- Use an ARM-based Mac.
- Ensure Constrained Language Mode is disabled.
PS> $ExecutionContext.SessionState.LanguageMode
FullLanguage- Parse a script containing the
Configurationkeyword.
$errors = $null
[System.Management.Automation.PSParser]::Tokenize("Configuration MyConfig {}",[ref]$errors)- View the resulting errors.
PS> $errors
Token Message
----- -------
System.Management.Automation.PSToken Configuration keyword is not allowed in constrainedLanguage mode.
Expected behavior
The Configuration keyword should be supported, or the error message should accurately state why it's not supported.
Actual behavior
The error message claims constrainedLanguage mode is enabled, which isn't true.
I believe this is caused by this block of code, which checks that either:
- ConstrainedLanguage mode is enabled, or
- The processor type is ARM.
PowerShell/src/System.Management.Automation/engine/parser/Parser.cs
Lines 2987 to 2995 in c3a080c
| // Configuration is not supported on ARM or in ConstrainedLanguage | |
| if (PsUtils.IsRunningOnProcessorArchitectureARM() || Runspace.DefaultRunspace.ExecutionContext.LanguageMode == PSLanguageMode.ConstrainedLanguage) | |
| { | |
| ReportError(configurationToken.Extent, | |
| nameof(ParserStrings.ConfigurationNotAllowedInConstrainedLanguage), | |
| ParserStrings.ConfigurationNotAllowedInConstrainedLanguage, | |
| configurationToken.Kind.Text()); | |
| return null; | |
| } |
It uses the same error message ("Configuration keyword is not allowed in constrainedLanguage mode.") even if the real issue is that I'm using an ARM processor.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0