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

Dead code elimination doesn't work well with nested try #4003

Open
edemaine opened this issue Dec 14, 2024 · 0 comments
Open

Dead code elimination doesn't work well with nested try #4003

edemaine opened this issue Dec 14, 2024 · 0 comments

Comments

@edemaine
Copy link

Playground link

Input code

let workerPool

export function compile(src, options) {
  if (process.env.CIVET_THREADS != 0) {
    const threads = Number(options.threads ?? process.env.CIVET_THREADS)
    if (!isNaN(threads) && threads > 0 && !options.sync) {
      try {
        workerPool = new WorkerPool(options.threads)
      }
      catch {
        workerPool = null
      }
    };return
  };return
}

Current output

(() => {
  // entry.js
  function compile(src, options) {
    if (0 && !isNaN(threads) && threads > 0 && !options.sync)
      try {
      } catch {
      }
  }
})();

Expected output

(() => {
})();

Additional info

Removing the try/catch block results in the expcted output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant