Skip to content

fix: Prevent panic in semantic highlighting for unknown token types #7189

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 22, 2025

Conversation

JoshuaBatty
Copy link
Member

@JoshuaBatty JoshuaBatty commented May 21, 2025

Description

Previously, the language server would panic if it encountered a SymbolKind that mapped to a SemanticTokenType not present in the SUPPORTED_TYPES array. This was due to an unwrap() call in the type_index function.

This PR addresses the issue by:
Adding SemanticTokenType::new("traitType") to the SUPPORTED_TYPES array, which was the specific missing type causing a crash when opening sway-lib-std/src/iterator.sw.

Modifying type_index to return Option<u32> instead of u32, removing the unwrap().

closes #7188

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@JoshuaBatty JoshuaBatty requested a review from a team as a code owner May 21, 2025 05:04
@JoshuaBatty JoshuaBatty self-assigned this May 21, 2025
@JoshuaBatty JoshuaBatty added bug Something isn't working language server LSP server labels May 21, 2025
@JoshuaBatty JoshuaBatty enabled auto-merge (squash) May 21, 2025 05:06
Copy link

codspeed-hq bot commented May 21, 2025

CodSpeed Performance Report

Merging #7189 will not alter performance

Comparing josh/lsp_std_lib (bde7580) with master (5a95c65)

Summary

✅ 24 untouched benchmarks

sdankel
sdankel previously approved these changes May 21, 2025
@JoshuaBatty JoshuaBatty requested a review from a team May 21, 2025 05:23
@JoshuaBatty JoshuaBatty merged commit a70254b into master May 22, 2025
43 checks passed
@JoshuaBatty JoshuaBatty deleted the josh/lsp_std_lib branch May 22, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language server LSP server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LSP crashes when opening the std lib iterator.sw file
4 participants