Skip to content
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

[BUG] NEXT in FOR/NEXT loop not recognized if preceded by a Label #104

Closed
brentlblair opened this issue Jun 1, 2020 · 5 comments · Fixed by #106
Closed

[BUG] NEXT in FOR/NEXT loop not recognized if preceded by a Label #104

brentlblair opened this issue Jun 1, 2020 · 5 comments · Fixed by #106
Assignees
Labels
bug Something isn't working resolved Issue resolved or enhancement added
Milestone

Comments

@brentlblair
Copy link
Contributor

Describe the bug
It the text and attached image, the Lint does not see shows a missing NEXT L for the FOR L. It highlights the error under the NEXT L that is saying is missing.

To Reproduce
FOR P=1 TO NUM.PARTS
FOR L=1 TO LOC.CNT
THIS.AVAIL.QTY=PARTS.ARRAY<7,P,L>
ORDER.QTY=PARTS.ARRAY<5,P>
IF THIS.AVAIL.QTY >= ORDER.QTY THEN
PARTS.ARRAY<11,P>=PARTS.ARRAY<8,P,L>
GOTO 103
END
NEXT L
IF PARTS.ARRAY<11,P>="" THEN GOSUB BACKORDER.LOCATION.CHECK
103
NEXT P

Screenshots
Code_jWfFWF3H8m

@kpowick
Copy link
Member

kpowick commented Jun 1, 2020

I am unable to reproduce this problem using the code example that you provided.

Which version of the extension are you using? The latest is 2.0.6.

@dthiot
Copy link
Contributor

dthiot commented Jun 1, 2020 via email

@brentlblair
Copy link
Contributor Author

brentlblair commented Jun 1, 2020 via email

@kpowick
Copy link
Member

kpowick commented Jun 1, 2020

You are correct that the numbered label preceding the NEXT is causing the issue. We'll have to look into that for the next release. Thanks for reporting it!

As you noted, you can use CONTINUE, or you can just put the label on a line by itself.

         CALL GET.PRODUCT.AVAILABILITY.SOE(BASE.PN,AVAIL,CHECK.LOC)
         PARTS.ARRAY<7,P,L>=AVAIL    ;*AVAIL BY SUBVALUED BY LOCATION
102:
       NEXT L
     NEXT P

Also there are some cases where there is a loop inside
of a loop, and I need to BREAK from the inner loop, and CONTINUE to the
outer loop. Sometimes that is just easier with a line number.

I get it, especially when porting a codebase to a different platform. However, in the case you describe, I would probably set a flag on the inner loop so that if one uses EXIT or BREAK to jump out, the outer loop "knows" to CONTINUE instead of process.

FOR J = 1 TO 10
   IS.COMPLETE = @TRUE
   FOR K = 1 TO 10
      IF {condition} THEN
         IS.COMPLETE = @FALSE
         EXIT
      END
   NEXT K
   IF NOT(IS.COMPLETE) THEN CONTINUE
   {Processing}
NEXT J

@kpowick kpowick added the bug Something isn't working label Jun 1, 2020
@kpowick kpowick added this to the v2.0.7 milestone Jun 1, 2020
@kpowick kpowick changed the title [BUG] Lint does not see NEXT in FOR NEXT loop [BUG] NEXT in FOR/NEXT loop not recognized if preceded by a Label Jun 1, 2020
@kpowick kpowick self-assigned this Jun 1, 2020
@kpowick
Copy link
Member

kpowick commented Jun 1, 2020

BTW, I'm working on other aspects for FOR/NEXT tracking that allow things like NEXT with no named variable. So, I'll look into this new problem as well.

Again, thanks for reporting it.

@kpowick kpowick added the resolved Issue resolved or enhancement added label Jun 10, 2020
kpowick pushed a commit that referenced this issue Jun 10, 2020
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.
@itsxallwater itsxallwater linked a pull request Jun 11, 2020 that will close this issue
itsxallwater added a commit that referenced this issue Jun 11, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
itsxallwater added a commit that referenced this issue Jun 11, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
itsxallwater added a commit that referenced this issue Sep 1, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

* Issue #110: Do not change indentation of comment lines

* Issue #111: Added user setting to control indentation of comment lines.

* Bump elliptic from 6.5.2 to 6.5.3 (#119)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Extension Guide.md

Updated AccuTerm connector and host program links.

* Feature request 113 (#121)

* Update package.json

Added MVBasic.customFunctionPath

* Update server.ts

added functionality to Load CustomFunction definition

* Add files via upload

* Update Extension Guide.md

added documentation for Custom functions and subroutines 6.8

* Update server.ts

Removed `data: functions[i].index,` for now since Microsoft has not responded yet.  It works without it, and it's no longer in the Microsoft API documentation.

* - Fix issue with startLoop/endLoop in server code parser
- Clean up unused variable in server
- Expand docs on new customFunctions feature

* Shipping 2.0.9

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brent Blair <[email protected]>
itsxallwater added a commit that referenced this issue Sep 2, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

* Issue #110: Do not change indentation of comment lines

* Issue #111: Added user setting to control indentation of comment lines.

* Bump elliptic from 6.5.2 to 6.5.3 (#119)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Extension Guide.md

Updated AccuTerm connector and host program links.

* Feature request 113 (#121)

* Update package.json

Added MVBasic.customFunctionPath

* Update server.ts

added functionality to Load CustomFunction definition

* Add files via upload

* Update Extension Guide.md

added documentation for Custom functions and subroutines 6.8

* Update server.ts

Removed `data: functions[i].index,` for now since Microsoft has not responded yet.  It works without it, and it's no longer in the Microsoft API documentation.

* - Fix issue with startLoop/endLoop in server code parser
- Clean up unused variable in server
- Expand docs on new customFunctions feature

* Shipping 2.0.9

* Update server.ts

It looks like I left the line `customFunctionPath = settings.MVBasic.customFunctionPath;` out of the merge.

* Shipping v2.0.10

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brent Blair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue resolved or enhancement added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants