feat: cfg-based unreachable diagnostics - #2316
Conversation
Summary of ChangesHello @hongjr03, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a robust Control-Flow Graph (CFG) analysis capability for Typst code, which is then immediately applied to significantly improve the accuracy and detail of unreachable code detection within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant improvement to unreachable code detection by implementing a CFG-based analysis. The new cfg module in tinymist-analysis is well-structured, and the implementation of CFG construction and dominator analysis appears solid. The linter in tinymist-lint is cleanly updated to use this new analysis.
A major highlight of this PR is the refactoring in tinymist to use a CompileHook trait. This greatly improves modularity by separating concerns like diagnostics, linting, preview updates, and exports into their own hooks. This is an excellent architectural improvement.
The addition of comprehensive tests for various unreachable code scenarios is also very valuable.
I have a few minor suggestions for improving code clarity and consistency, but overall this is a high-quality contribution.
…ting compiler/lint diagnostics
…iagnostic management
…mpiler diagnostics and a new `LintHook` for lint-specific diagnostics.
…, replacing individual handlers for diagnostics, linting, preview, and export.
…ector initialization.
- Add new cfg module in tinymist-analysis for control-flow graph construction - Implement unreachable code linting by detecting orphan blocks in CFG - Build CFG directly from Typst AST for accurate control flow analysis
|
Closed in favor of #2321. |
This depends on and should be merged after #2302.
Add CFG construction and basic graph analysis interfaces based on the Typst AST in
tinymist-analysis; rewrite the unreachable diagnostic intinymist-lintusing CFG reachability to improve span coverage and support reporting multiple consecutive unreachable segments; and add snapshot tests for unreachable intinymist-query.