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

Crash when I have an empty code mark after one or more non-empty code marks. #1

Closed
3 tasks done
ghv opened this issue Apr 29, 2020 · 0 comments
Closed
3 tasks done
Assignees

Comments

@ghv
Copy link
Owner

ghv commented Apr 29, 2020

  • Provide a description of what the bug is about
  • Provide a minimal code snippet / example that reproduces the bug.
  • Provide a description of what you believe the output show be.

I am seeing a crash, "Fatal error: Index out of range" in updateBeginEndTailComments when the input looks like this:

            import Foundation
            import AppKit

            /*SVMPREFS
            S main | | RALL

            V Bool | boolVar1    | boolVar2 | IS |
            V Bool | hasBoolVar2 | boolVar2 | |
            V Bool | boolVar3    | boolVar3 | |
            V Bool | boolVar4    | boolVar4 | |

            S copy | | RALL

            V Bool | boolVar3 | boolVar3 | |
            V Bool | boolVar4 | boolVar4 | |

            M main | copy   | boolVar3 | boolVar3
            M main | copy   | boolVar4 | boolVar4
            M main | delete | hasBoolVar2

            SVMPREFS*/

            class MyMigrationTests {
                // MARK: BEGIN main
                // this will be deleted
                // MARK: END main

                // MARK: BEGIN copy
                // this will be deleted
                // MARK: END copy

                // MARK: BEGIN migrate
                // MARK: END migrate
            }

The migrate code mark has no code to delete and is therefore not having its code mark begin and code mark end indexes updated when removing the existing code between all code marks.

It should adjust these indexes because there are code marks for which there was some code to be deleted above it.

It is also possible that this would not crash if there are more lines after the empty code marks equal or greater in length to the number of lines removed in prior code marks. In this case the code would get inserted in the wrong place.

@ghv ghv self-assigned this Apr 29, 2020
ghv pushed a commit that referenced this issue Apr 29, 2020
ghv added a commit that referenced this issue Apr 29, 2020
Fixing issue #1 in removeGeneratedLines
@ghv ghv closed this as completed Apr 30, 2020
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

No branches or pull requests

1 participant