Skip to content

Conversation

@JsonFreeman
Copy link
Contributor

Code copied from bug #1503 for convenience. This fixes #1503.

module Z.M {
    export function bar() {
        console.log(1);
    }
}
module A.M {
    import M = Z.M;
    export function bar() {
        console.log(2);
    }
    M.bar(); // Calls the wrong function at runtime, works if you change the above import to a var
}

The issue is that we were not generating a unique name _M for the module A.M. We need to do this because of the local import M, which we were ignoring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test case for when you don't reference the import.

@yuit
Copy link
Contributor

yuit commented Dec 17, 2014

lgtm 👍 About the test case 3 and case 5, I don't mind the fact that they are different as these are emit output from error-ed file

JsonFreeman added a commit that referenced this pull request Dec 17, 2014
Fix issue #1503 with modules and imports sharing a name
@JsonFreeman JsonFreeman merged commit de062ae into release-1.4 Dec 17, 2014
@JsonFreeman JsonFreeman deleted the moduleSharesNameWithImportInside branch December 17, 2014 22:49
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants