Skip to content

Compiler (still) crashes with "Declaration to checkResolvedBlockScopedVariable is undefined" #27134

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

Closed
felixfbecker opened this issue Sep 17, 2018 · 6 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@felixfbecker
Copy link
Contributor

Similar/same as #27061, but still happening in 3.1.0-dev.20180915.

Introduced in 3.1.0-dev.20180906, last working version was 3.1.0-dev.20180905.

Stack trace:

Debug Failure. Declaration to checkResolvedBlockScopedVariable is undefined

    at checkResolvedBlockScopedVariable (node_modules/typescript/lib/typescript.js:31697:33)
    at resolveNameHelper (node_modules/typescript/lib/typescript.js:31538:25)
    at resolveName (node_modules/typescript/lib/typescript.js:31219:20)
    at getResolvedSymbol (node_modules/typescript/lib/typescript.js:43026:21)
    at checkIdentifier (node_modules/typescript/lib/typescript.js:44474:26)
    at checkExpressionWorker (node_modules/typescript/lib/typescript.js:50599:28)
    at checkExpression (node_modules/typescript/lib/typescript.js:50571:42)
    at checkNonNullExpression (node_modules/typescript/lib/typescript.js:47062:37)
    at checkPropertyAccessExpressionOrQualifiedName (node_modules/typescript/lib/typescript.js:47088:28)
    at checkPropertyAccessExpression (node_modules/typescript/lib/typescript.js:47081:20)

TypeScript Version: 3.1.0-dev.20180915

@Kingwl
Copy link
Contributor

Kingwl commented Sep 17, 2018

image

cannot recurrent

@felixfbecker
Copy link
Contributor Author

@Kingwl I am not saying that code triggers it. I don't know what triggers this, it's a codebase with thousands of lines of code, it could be anything. But the stack trace is real

@Kingwl
Copy link
Contributor

Kingwl commented Sep 17, 2018

🤷🏻‍♂️

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Sep 21, 2018
@minestarks
Copy link
Member

@RyanCavanaugh I have a quite a few repros of this

Version 3.1.0-dev.20180925

git clone --depth=1 https://github.com/adobe/brackets
cd brackets
tsc --init
tsc --allowJs --checkJs
Error: Debug Failure. Declaration to checkResolvedBlockScopedVariable is undefined
    at checkResolvedBlockScopedVariable (node_modules\typescript\lib\tsc.js:25937:33)
    at resolveNameHelper (node_modules\typescript\lib\tsc.js:25788:25)
    at resolveName (node_modules\typescript\lib\tsc.js:25555:20)
    at resolveEntityName (node_modules\typescript\lib\tsc.js:26243:26)
    at resolveTypeReferenceName (node_modules\typescript\lib\tsc.js:31245:20)
    at getTypeFromTypeReference (node_modules\typescript\lib\tsc.js:31412:30)
    at checkTypeReferenceNode (node_modules\typescript\lib\tsc.js:42928:24)
    at checkSourceElement (node_modules\typescript\lib\tsc.js:45932:28)
    at Object.forEach (node_modules\typescript\lib\tsc.js:169:30)
    at checkUnionOrIntersectionType (node_modules\typescript\lib\tsc.js:42993:16)

@RyanCavanaugh
Copy link
Member

Validated 3.1 call stack. Regression from 3.0.

@RyanCavanaugh
Copy link
Member

Simplest repro

/**
 * @enum {number}
 */
var foo = { };

/**
 * @type {foo}
 */
var s;

The problem here is that foo is being used as a "type" but we filter out all non-block-scoped declarations, and var is not a block-scoped declaration. I think the filtering is wrong in this case?

Failure here:

        function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
            Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum));
            // Block-scoped variables cannot be used before their definition
            const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined);

            if (declaration === undefined) return Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined");

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript and removed Needs More Info The issue still hasn't been fully clarified labels Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants