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

StatementedNode uses inconsistent source for child count #312

Closed
dsherret opened this issue Apr 14, 2018 · 0 comments
Closed

StatementedNode uses inconsistent source for child count #312

dsherret opened this issue Apr 14, 2018 · 0 comments
Labels

Comments

@dsherret
Copy link
Owner

I noticed when inserting incorrect syntax:

export type compilerVersions = "2.8.1" | "2.6.2" | "2.7.2";

export enum CompilerVersion {
    typescript = "2.8.1",
    typescript-2.6.2 = "2.6.2",
    typescript-2.7.2 = "2.7.2"
}

That when then calling:

sourceFile.addFunction({...});

It would throw this error:

V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\errors\BaseError.js:16
        var _this = _super.call(this, message) || this;
                           ^
Error: Invalid index: The max index is 5, but 6 was specified.
    at InvalidOperationError.BaseError [as constructor] (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\errors\BaseError.js:16:28)
    at new InvalidOperationError (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\errors\InvalidOperationError.js:17:28)
    at Object.verifyAndGetIndex (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\manipulation\helpers\verifyAndGetIndex.js:14:15)
    at Object.insertIntoBracesOrSourceFileWithGetChildren (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\manipulation\manipulations\insertion.js:135:27)
    at SourceFile.StatementedNode.class_1._insertChildren (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:397:35)
    at SourceFile.StatementedNode.class_1.insertFunctions (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:168:25)
    at SourceFile.StatementedNode.class_1.addFunctions (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:161:25)
    at SourceFile.StatementedNode.class_1.addFunction (V:\ts-ast-viewer\node_modules\ts-simple-ast\dist\compiler\statement\StatementedNode.js:158:25)
    at Object.<anonymous> (V:\ts-ast-viewer\scripts\createCompilerVersions.ts:35:22)
    at Module._compile (module.js:624:30)

The problem is that StatementedNode uses one source for the child count in the add methods and a different one when verifying the index is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant