# Statements after an unconditional return

Source: https://findproxyforurl.net/rules/unreachable-code/ · last updated 2026-10-04

Rule PAC-E016 (`unreachable-code`), severity medium, category: Errors and robustness.

Statements that follow a return in the same block are never executed. Rules placed there look active but have no effect.

## Why it matters

In PAC files this usually happens when a `return "PROXY ..."` default is placed in the
middle of the function and further `if` blocks are appended after it. Those later rules
never run. The PAC passes every test that happens to hit the earlier branches, and the
operator wonders why the new exception "does not work".


## How to fix

Move the unconditional return to the end of the function; delete code that is really obsolete.

## Bad

```js
function FindProxyForURL(url, host) {
  if (isPlainHostName(host)) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (isPlainHostName(host) || dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```
