1

Closed

Exception when getting diagnostics

description

I'm trying out the latest develop branch code in the Eclipse plug-in and hit this exception:
TypeError: Cannot read property '0' of null
    at PullTypeResolver.typeCheckObjectCreationExpression (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:45115:95)
    at PullTypeResolver.typeCheckAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42893:33)
    at PullTypeResolver.resolveAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42577:22)
    at PullTypeResolver.resolveReturnStatement (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42418:56)
    at PullTypeResolver.typeCheckAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:43000:33)
    at PullTypeResolver.resolveAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42577:22)
    at PullTypeResolver.resolveList (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:41901:26)
    at PullTypeResolver.resolveAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42585:33)
    at PullTypeResolver.resolveBlock (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42299:22)
    at PullTypeResolver.resolveAST (/Users/dcicerone/git/eclipse-typescript/com.palantir.typescript/bin/bridge.js:42788:33)
The line number corresponds to:
var contextualType = callResolutionData.actualParametersContextTypeSymbols[i];
in:
        PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, inContextuallyTypedAssignment, enclosingDecl, context) {
            this.setTypeChecked(callEx, context);
            this.resolveAST(callEx.target, inContextuallyTypedAssignment, enclosingDecl, context);
            var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx);
            if (callEx.arguments) {
                var callResolutionData = this.currentUnit.getCallResolutionDataForAST(callEx);
                var len = callEx.arguments.members.length;

                for (var i = 0; i < len; i++) {
                    var contextualType = callResolutionData.actualParametersContextTypeSymbols[i];
                    if (contextualType) {
                        context.pushContextualType(contextualType, context.inProvisionalResolution(), null);
                    }

                    this.resolveAST(callEx.arguments.members[i], contextualType != null, enclosingDecl, context);

                    if (contextualType) {
                        context.popContextualType();
                        contextualType = null;
                    }
                }
            }
        };
Sorry I don't have more specific repro steps - this occurs when retrieving diagnostics for every TypeScript file in our workspace via the Eclipse plug-in. Hopefully the stack trace is enough to determine the issue.
Closed Oct 8, 2013 at 12:13 AM by RyanCavanaugh
Yep, that's the commit. Thanks for the help investigating this one.

comments

RyanCavanaugh wrote Sep 16, 2013 at 11:05 PM

Thanks for reporting this. It's not clear how the compiler got into this state, but we have some tools we can run to try to reproduce the issue that we can run if you could upload the file(s) you were working on when you got this. We do a lot of fuzzing-type edits on the language service and have never seen this, so there may be something special in the codebase that we need to test on.

As always, please "re-open" the issue if you can provide more information. Thanks!

** Closed by RyanCavanaugh 09/16/2013 4:05PM

derekcicerone wrote Sep 17, 2013 at 9:21 AM

I don't think I'll be able to provide the entire code base but I could send the single file that seems to trigger this issue. I'd prefer not to upload it publicly though - is there an email address where I could send it?

derekcicerone wrote Sep 28, 2013 at 10:50 PM

Ok, I dug into this a bit more and I think I can see why this might be failing now: this is somewhat "special" call.

The code causing the exception looks like this:
    public static create(renderer, xscale, yscale, renderers, datasets, intrabarPadding: any = 25) {
        // A Renderer is a class that given a graphical context,
        // a set of scales, and a series of data, draws nice charts
        // onto a plot.
        if (this.classes[renderer.type] != null) {
            return new this.classes[renderer.type](renderer, xscale, yscale, renderers, datasets, intrabarPadding);
        }
    }
Does this provide enough information to figure out how to fix it or do you need more context?

derekcicerone wrote Sep 28, 2013 at 10:54 PM

(the failure is from the "return new this.classes..." line)

derekcicerone wrote Sep 28, 2013 at 10:57 PM

classes looks like this:
    public static classes = {
        "LineXYRendererModel": LineRenderer,
        "PointsXYRendererModel": PointsRenderer,
        "BarXYRendererModel": BarRenderer,
        "CustomSideBySideCategoryXYBarRendererModel": CustomSideBySideCategoryBarRenderer,
        "CustomStackedSideBySideCategoryXYBarRendererModel": CustomSideBySideCategoryBarRenderer,
        "AreaXYRendererModel": AreaRenderer,
        "DateSetXYRendererModel": DateSetRenderer
    };

derekcicerone wrote Sep 28, 2013 at 11:07 PM

This code successfully works around the issue:
export function create(renderer, xscale, yscale, renderers, datasets, intrabarPadding = 25) {
    switch (renderer.type) {
        case "LineXYRendererModel":
            return new LineRenderer(renderer, xscale, yscale, renderers, datasets);
        case "PointsXYRendererModel":
            return new PointsRenderer(renderer, xscale, yscale, renderers, datasets);
        case "BarXYRendererModel":
            return new BarRenderer(renderer, xscale, yscale, renderers, datasets);
        case "CustomSideBySideCategoryXYBarRendererModel":
            return new CustomSideBySideCategoryBarRenderer(renderer, xscale, yscale, renderers, datasets, intrabarPadding);
        case "CustomStackedSideBySideCategoryXYBarRendererModel":
            return new CustomSideBySideCategoryBarRenderer(renderer, xscale, yscale, renderers, datasets, intrabarPadding);
        case "AreaXYRendererModel":
            return new AreaRenderer(renderer, xscale, yscale, renderers, datasets);
        case "DateSetXYRendererModel":
            return new DateSetRenderer(renderer, xscale, yscale, renderers, datasets);
    }
}

RyanCavanaugh wrote Sep 30, 2013 at 5:25 PM

We're still trying to repro this (or come up with a theory of how it happens) without any luck. Can you send me whatever you can to ryanca@microsoft.com? Thanks!

derekcicerone wrote Sep 30, 2013 at 6:29 PM

Sent the file which causes the issue.

derekcicerone wrote Oct 4, 2013 at 2:01 AM

I'm guessing this is the fix: https://typescript.codeplex.com/SourceControl/changeset/1858145a4e293437b09467b08767305a48c5e3b1. Can't reproduce the issue with the latest develop code.