Skip to content
New issue

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

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

Already on GitHub? # to your account

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

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

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.

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

No branches or pull requests

1 participant