This release marks a massive step forward in the power and stability of the Mago analyzer. We're thrilled to introduce a completely rewritten match
expression analyzer and a new, optional check for unhandled exceptions.
As a sign of our growing confidence in the tool's stability, the large "EXPERIMENTAL" warning has been removed from the analyze
command. This release also includes significant refactoring and polish for both the analyzer and the formatter.
✨ Major Analyzer Features
All-New match
Analyzer
The match
expression analyzer has been completely rewritten from the ground up to resolve numerous bugs and correctness issues. The new implementation correctly simulates match
semantics by sequentially analyzing each arm and narrowing the subject's type, providing far more accurate and useful diagnostics.
Key capabilities include:
- Accurate Exhaustiveness Checking
- Precise Unreachable Code Detection
- Redundant Condition Analysis
- Correct Type Inference for the
match
expression's result
New: Unhandled Exception Checking
A new, powerful check for unhandled exceptions has been added. This is an opt-in feature, disabled by default, which can be enabled with the check_throws = true
config setting or the --check-throws=true
CLI flag. When active, it will report an unhandled-thrown-type
error if a function or method can throw an exception that is neither caught nor documented in a @throws
tag.
⚙️ Analyzer Improvements & Fixes
- Improved Error Messages: Diagnostics for by-reference constraint conflicts are now significantly clearer and more helpful.
- Improved Pragma Applicability (#146): It is now possible to suppress file-level issues, as
@mago-expect
comments now apply to any issue that contains them (in addition to issues they contain). - Internal Refactoring: The logic for reconciling context between conditional branches (
if
,switch
,try
, etc.) has been centralized, and a large amount of dead code has been removed from the analyzer's core, improving maintainability.
💅 Formatter Polish
- More Opinionated, Less Configuration: A number of rarely-used, stylistic options have been removed to promote a single, consistent formatting style across all projects.
- Intelligent Comment Formatting (#296): The formatter now preserves custom prefixes in multi-line block comments, correctly formatting decorative blocks (like those in Laravel config files) without destroying their layout.
- Bug Fixes: Resolved several idempotency issues related to newlines after
use
statements, comments around the closing parenthesis of function calls, and parenthesis handling for unary operators.
✔️ Closed Issues
This release closes the following issues:
Full Changelog: 1.0.0-alpha.10...1.0.0-alpha.11