Files
compiler-explorer/lib/tooling
Matt Godbolt ec1ac47033 Fix any types for delayCleanupTemp and toolchainPath (#8409)
## Summary

- Fixed `delayCleanupTemp: any` → `boolean`
- Fixed `toolchainPath: any` → `string | undefined`
- Changed `getToolchainPath()` to return `string | undefined` instead of
`string | false` (more idiomatic TypeScript)
- Fixed a latent bug in `changeOptionsBasedOnOverrides`

### Bug fix details

The bug was introduced in commit 079d49575 ("Compiler overrides #5001")
on May 16, 2023.

The original **correct** code (from commit 86a84f7f6) was:
```typescript
let sysrootPath: string | undefined;
const overriddenToolchainPath = this.getOverridenToolchainPath(overrides);
if (overriddenToolchainPath) {
    sysrootPath = getSysrootByToolchainPath(overriddenToolchainPath);
}
```

The buggy refactor changed it to:
```typescript
const sysrootPath = overriddenToolchainPath ?? 
    getSysrootByToolchainPath(overriddenToolchainPath);
```

This had two issues:
1. **The fallback was never reached**: `false ?? x` returns `false`
because `false` is not nullish (only `null`/`undefined` trigger `??`)
2. **The fallback passed the wrong variable**: It passed
`overriddenToolchainPath` to the fallback, but when the fallback is
needed, that variable would be `false`/`undefined`

Fixed to match the original correct behaviour:
```typescript
const sysrootPath = overriddenToolchainPath
    ? getSysrootByToolchainPath(overriddenToolchainPath)
    : this.toolchainPath
      ? getSysrootByToolchainPath(this.toolchainPath)
      : undefined;
```

The sysroot is now always computed via `getSysrootByToolchainPath()`,
since toolchain paths (e.g. `/opt/compiler-explorer/gcc-7.2.0`) differ
from sysroot paths (e.g.
`/opt/compiler-explorer/gcc-7.2.0/x86_64-pc-linux-gnu/sysroot`).

## Test plan
- [x] `npm run ts-check` passes
- [x] `npm run test-min` passes
- [x] Pre-commit hooks pass

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 21:31:18 -06:00
..
2025-07-28 10:34:46 -05:00
2025-03-14 16:59:27 +01:00