Skip to content

Infinite loop in emitter on class with parameter property of object type in module #325

Description

@danquirk
module A {
    class C {
        constructor(public d: { foo: any }) { }
    }
}

Gets stuck here in emitter.ts:

        function isUniqueLocalName(name: string, container: Node): boolean {
            for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) {
                if (node.locals && hasProperty(node.locals, name) && node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
                    return false;
                }
            }
            return true;
        }

because in binder.ts we set something up incorrectly:

        // All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function
        // in the type checker to validate that the local name used for a container is unique.
        function bindChildren(node: Declaration, symbolKind: SymbolFlags) {
            if (symbolKind & SymbolFlags.HasLocals) {
                node.locals = {};
            }
            var saveParent = parent;
            var saveContainer = container;
            parent = node;
            if (symbolKind & SymbolFlags.IsContainer) {
                container = node;
                if (lastContainer) {
                    Debug.assert(lastContainer !== container); // assert fails
                    lastContainer.nextContainer = container;
                }
                lastContainer = container;
            }
            forEachChild(node, bind);
            container = saveContainer;
            parent = saveParent;
        }
Error: Debug Failure. False expression:
    at Object.assert (D:\GitHub\TypeScript\built\local\tc.js:2043:23)
    at bindChildren (D:\GitHub\TypeScript\built\local\tc.js:5359:30)
    at bindAnonymousDeclaration (D:\GitHub\TypeScript\built\local\tc.js:5428:13)
    at bind (D:\GitHub\TypeScript\built\local\tc.js:5482:21)
    at child (D:\GitHub\TypeScript\built\local\tc.js:2348:24)
    at Object.forEachChild (D:\GitHub\TypeScript\built\local\tc.js:2370:44)
    at bindChildren (D:\GitHub\TypeScript\built\local\tc.js:5364:16)
    at bindDeclaration (D:\GitHub\TypeScript\built\local\tc.js:5404:13)
    at D:\GitHub\TypeScript\built\local\tc.js:5410:21
    at Object.forEach (D:\GitHub\TypeScript\built\local\tc.js:1586:30)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueHigh Priority

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions