Skip to content

Root-level resources with usings not being disposed #1632

@inklesspen1rus

Description

@inklesspen1rus

Title says the problem.

Simple snippet:

class A {
    [Symbol.dispose] = function (this: A) {
        print('Dispose')
    }
}
using a = new A();

Translates into this:

A = __TS__Class()
A.name = "A"
function A.prototype.____constructor(self)
    self[Symbol.dispose] = function(self)
        print("Dispose")
    end
end
a = __TS__New(A)
-- Here is no disposing

While scoping it with brackets causing generating __TS__Using:

{
using a = new A();
}
do
    return __TS__Using(
        nil,
        function(a)
        end,
        __TS__New(A)
    )
end

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