Files
compiler-explorer/static
Matt Godbolt 2a4e688ff2 Fix null reference errors in gccdump view selection handling (#7764)
## Summary

Fixes two related null reference errors in the GCC dump view's TomSelect
dropdown handling that occur during user interactions.

## Root Cause Analysis

**COMPILER-EXPLORER-96P** (1067 occurrences):
- Error: `TypeError: undefined is not an object (evaluating
't.filename_suffix')`
- Location: `gccdump-view.ts:318` in `onPassSelect()`
- Trigger: User deletes a selection via TomSelect → `deleteSelection()`
→ `removeItem()` → `trigger('change')` → `onPassSelect()` called with
passId that no longer exists in `this.selectize.options`

**COMPILER-EXPLORER-E44** (34 occurrences):
- Error: `TypeError: Cannot read properties of undefined (reading '0')`
- Location: `gccdump-view.ts:237` in dropdown open handler
- Trigger: `find()` returns undefined when searching for pass by
filename_suffix, but code uses non-null assertion `activeOption![0]`

Both errors occur due to timing issues when dropdown options are being
updated while user interactions are happening.

## Changes

1. **Added null check in `onPassSelect()`**: Safely handle case where
`this.selectize.options[passId]` returns undefined
2. **Removed unsafe non-null assertion**: Replace `activeOption![0]`
with proper null check and early return
3. **Added CLAUDE.md guidance**: Include preference for modern
TypeScript features like optional chaining

## Impact

- Prevents crashes with 1100+ reported occurrences combined
- Maintains existing user experience - dropdowns continue to work
normally
- No behavioral changes for valid interactions

Fixes COMPILER-EXPLORER-96P
Fixes COMPILER-EXPLORER-E44

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-09 11:00:27 -05:00
..
2025-05-19 06:51:21 -05:00
2025-02-26 02:07:09 +02:00
2025-02-26 02:07:09 +02:00
2025-02-26 02:07:09 +02:00
2024-10-25 12:19:04 +03:00
2025-04-24 12:10:37 -05:00
2025-04-24 12:10:37 -05:00
2025-04-24 18:41:55 -05:00