mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-05-16 18:23:01 -04:00
## 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 commit079d49575("Compiler overrides #5001") on May 16, 2023. The original **correct** code (from commit86a84f7f6) 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>