Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.dfa.fast.report
Reporting mechanism for the fast Data Flow Analysis engine.
This module translates the abstract state of the DFA into concrete compiler errors.
It is responsible for:
- Null Checks: Reporting errors when null pointers are dereferenced.
- Contract Validation: Ensuring functions fulfill their out contracts (e.g., returning non-null).
- Logic Errors: Detecting assertions that are provably false at compile time.
Authors:
License:
Source dfa/fast/report.d
Documentation https://dlang.org/phobos/dmd_dfa_fast_report.html
- struct
DFAReporter; - The interface for reporting DFA errors and warnings.This struct acts as the sink for all findings. It checks if a specific violation (like a null dereference) should be reported based on the variable's modellability and depth, then sends it to the global ErrorSink.
- void
onDereference(DFAConsequence*on, ref Locloc); - Reports an error if a variable is dereferenced while known to be null.This is triggered by expressions like *ptr or ptr.field when the DFA determines ptr has a Nullable.Null state.Parameters:
DFAConsequence* onThe consequence containing the variable state (must be Nullable). Loc locThe source location of the dereference. - void
onEndOfScope(FuncDeclarationfd, ref const Locloc); - Validates constraints at the end of a scope.This checks if output parameters (like out or ref parameters) meet their guaranteed post-conditions. For example, if a function parameter is marked to guarantee a non-null output, this ensures the variable is actually non-null when the scope exits.
- void
onAssertIsFalse(ref DFALatticeReflr, ref Locloc); - Reports an error if an assertion is statically provable to be false.If the DFA determines that the condition x in assert(x) is definitively false (e.g., assert(null) or assert(0) after analysis), it reports this logic error.
- void
onFunctionCallArgumentLessThan(DFAConsequence*c, ParameterDFAInfo*paramInfo, FuncDeclarationcalling, ref Locloc); - Reports an error if a function argument violates the callee's expectations.
Example Passing null to a function parameter marked as requiring non-null.
Copyright © 1999-2026 by the D Language Foundation | Page generated by
Ddoc on Wed Aug 5 15:41:18 2026