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.utils

Utilities for Data Flow Analysis.

Source dfa/utils.d

bool isTypeNullable(Type type);
Checks if a type is capable of being null at runtime.
The DFA uses this to determine if a null-check is required for a specific variable.
Returns:
true if the type is a pointer, array, class, delegate, etc.
bool isTypeTruthy(Type type);
Checks if a type can be evaluated as a boolean (truthy/falsey).
Used by the DFA to determine if control flow (like if statements) depends on this variable.
Returns:
false for types like void (noreturn) or struct (unless they define opCast), true for integers, pointers, bools, etc.
EqualityArgType equalityArgTypes(Type lhs, Type rhs);
Classifies how two types are compared for equality at runtime.
This mirrors the logic in the compiler backend/glue layer. The DFA needs this to accurately predict if an equality check (==) involves simple integer comparison, array comparison, or struct comparison.
See Also:
EqualityArgType