Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ts_dispose_resources is not correctly invoked for using keyword #9673

Open
jtbandes opened this issue Oct 23, 2024 · 0 comments
Open

_ts_dispose_resources is not correctly invoked for using keyword #9673

jtbandes opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@jtbandes
Copy link

jtbandes commented Oct 23, 2024

Describe the bug

The Symbol.dispose function is not invoked when using the using keyword.

The output includes

finally{
    _ts_dispose_resources(env);
}

However, this function is defined as

function _ts_dispose_resources(SuppressedError1) {
    return function(env) {
        // ...
    };
}

So calling _ts_dispose_resources(env); does not actually invoke the dispose logic.

The function does seem to be invoked here, so something else must be going wrong:

Input code

using x = {
  [Symbol.dispose]() {
    console.log("disposed")
  }
};

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false,
      "explicitResourceManagement":true
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.39&code=H4sIAAAAAAAAAystzsxLV6hQsFWo5lJQiA6uzE3Kz9FLySwuyC9OjdXQBAsrKCTn5xXn56Tq5eSnayhBZVOUNIFytVy11gBoxdWzRQAAAA%3D%3D&config=H4sIAAAAAAAAA1VPOw6DMAzdOQXyzFAx9g4svYGVGhSUn2IjgRB3bxIgbbe8f7w3bQszK3i2e3omEDAyxYoTw5sTXBMDpCyyijoIdLc6c5ZGNEwd0BqMVlpexH6JigZ0OJElJ%2FCUuFAJHWcWBONEUnq5f%2FT91QnGe6baeXJWOz1uv79S3oZIzP%2FGbEU3mZo%2FF5trFax%2FL0W8rpUtZJTbrHczw9d5L9Z20Dzc8XLM8QEIU%2BriPgEAAA%3D%3D

SWC Info output

No response

Expected behavior

console.log("disposed") should run

Actual behavior

No log message

Version

1.7.39

Additional context

See also #9576

@jtbandes jtbandes added the C-bug label Oct 23, 2024
@kdy1 kdy1 self-assigned this Oct 24, 2024
@kdy1 kdy1 added this to the Planned milestone Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants
@jtbandes @kdy1 and others