Skip to content

Revert "Make switch statement report correct error position when it fails to evaluate the condition" - #7182

Merged
Dongbo Wang (daxian-dbw) merged 5 commits into
masterfrom
revert-7151-error-position
Jun 26, 2018
Merged

Dongbo Wang (daxian-dbw) merged 5 commits into
masterfrom
revert-7151-error-position

Conversation

@daxian-dbw

Copy link
Copy Markdown
Member

Reverts #7151

The fix causes a problem in debugging. When stepping over the scripts in debugging mode, the debugger will stop at the switch statement condition expression twice at the very beginning -- one for evaluating the condition, and one for iterating the condition.

Here is an example:

PS:4> .\about.ps1
Entering debug mode. Use h or ? for help.

Hit Line breakpoint on 'F:\tmp\about.ps1:1'

At F:\tmp\about.ps1:1 char:1
+ $Test = 1;
+ ~~~~~~~~~
PS:4>> v
At F:\tmp\about.ps1:2 char:1
+ $b = 1..10
+ ~~~~~~~~~~
PS:4>> v
At F:\tmp\about.ps1:3 char:9
+ switch ($b) {
+         ~~
PS:4>> v
At F:\tmp\about.ps1:3 char:9
+ switch ($b) {
+         ~~
PS:4>> v
At F:\tmp\about.ps1:4 char:5
+     "a" {};
+     ~~~

@@ -1,51 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests still seem relevant though -- they do cover an existing bug and after it's fixed would check for regressions. We could keep them with a -Pending flag and track it with an issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests will be added back along with the next attempt to fix the issue.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 13e925e into master Jun 26, 2018
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the revert-7151-error-position branch June 26, 2018 19:24

@BrucePay Bruce Payette (BrucePay) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…ails to evaluate the condition" (PowerShell#7182)

The fix causes a problem in debugging. When stepping over the scripts in debugging mode, the debugger will stop at the switch statement condition expression twice at the very beginning -- one for evaluating the condition, and one for iterating the condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants