Skip to content

nested namespace merging accesses invalid global when referring to parent namespace #1431

@homomorphist

Description

@homomorphist
// (This is reproducible without the shorthand syntax.)
namespace Foo.Bar {}
namespace Foo.Bar {
    export const baz = 32;
}

export { Foo }
local ____exports = {}
local Foo = {}
do
    Foo.Bar = {}
end
do
    do
        Bar.baz = 32 -- `Bar` is not valid in this scope!
    end
end
____exports.Foo = Foo
return ____exports

I patched this this myself by changing transformation/visitors/namespace.ts's line 94 to remove (isNonModuleMergeable || isFirstDeclaration) from the condition, but I would presume the conditional was there in the first place to prevent some issue. I'm unfortunately currently unable to run the tests to confirm this, but so far my project seems okay. If that doesn't resolve it, hopefully it at least provides some sort of clue. :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions