Implement null-safety checker as DataFlow analysis#74
Draft
Copilot wants to merge 4 commits intosimn-developmentfrom
Draft
Implement null-safety checker as DataFlow analysis#74Copilot wants to merge 4 commits intosimn-developmentfrom
Copilot wants to merge 4 commits intosimn-developmentfrom
Conversation
- Add FlagNullAnalysis to cfg_edge_Flag - Extend DataFlowApi with 'narrow' for conditional narrowing at phi nodes - Implement NullAnalysisImpl with Top/NotNull/IsNull/Bottom lattice - Transfer function uses type-based nullability evaluation - Narrow function handles if(x==null)/if(x!=null) at phi merge points - Commit walks dominator tree with narrowing context for intra-block narrowing - Flags unsafe field access, method calls, array access on Null<T> values - Wire into analyzer pipeline conditional on -D analyzer-check-null - All existing optimization and unit tests pass Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Remove legacy @:analyzer(testIsNull/testIsNotNull) annotations. Replace with meaningful test methods that exercise null-check patterns: assignment, reassignment, null-check-then, null-check-else, nested checks, early return guards, break/continue in loops, throw guards. Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate implementation of null-safety checker
Implement null-safety checker as DataFlow analysis
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Investigates using the existing SSA-based
DataFlowmodule for null-safety checking. The framework is adequate with one extension: anarrowhook onDataFlowApifor refining phi incoming values based on edge conditions.DataFlow framework extension
narrow : analyzer_context -> opt_ctx -> cfg_edge -> texpr -> t -> ttoDataFlowApisignatureConstPropagationImpl,CopyPropagationImpl) use identity narrowingNullAnalysisImpl
Top | NotNull | IsNull | Bottom— tracks whether variables are provably non-null, provably null, or potentially nullNull<T>return types →Bottom, non-nullable →NotNull,TConst TNull→IsNullif (x == null)/if (x != null)through temp var lookups viaget_var_value, narrowing phi inputs on each branchWNullSafetywarnings for field access, method calls, and array access on potentially-nullNull<T>valuesActivated by
-D analyzer-check-null, runs after const/copy propagation and before local DCE.What works
Config / plumbing
FlagNullAnalysisadded tocfg_edge_Flagnull_safetyfield onAnalyzerConfig.t, readsanalyzer_check_nulldefineTestNullChecker.hx: removed legacy@:analyzer(testIsNull)annotations, replaced with test methods exercising null-flow patterns🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.