Fix stale diagnostics replayed after error is resolved#12863
Draft
Copilot wants to merge 3 commits intodevelopmentfrom
Draft
Fix stale diagnostics replayed after error is resolved#12863Copilot wants to merge 3 commits intodevelopmentfrom
Copilot wants to merge 3 commits intodevelopmentfrom
Conversation
add_module_diagnostic now only caches the message in m_cache_bound_objects when the message position is in the same file as the module. This prevents the shared m_cache_bound_objects DynArray (between a module loaded from the HXB binary cache and the cache entry itself) from being mutated by display diagnostics whose position is in a different file (e.g. a field-access diagnostic generated for Int's module when the access is in the user's file). Also add the m_processed=0 guard to module_warning to prevent the same shared-DynArray pollution for cached modules. Adds regression test Issue12861. Co-authored-by: Simn <634365+Simn@users.noreply.github.com> Agent-Logs-Url: https://github.com/HaxeFoundation/haxe/sessions/cada24b6-2ee7-42e2-b413-637d30bd2312
Co-authored-by: Simn <634365+Simn@users.noreply.github.com> Agent-Logs-Url: https://github.com/HaxeFoundation/haxe/sessions/cada24b6-2ee7-42e2-b413-637d30bd2312
Copilot
AI
changed the title
[WIP] Fix old diagnostics errors not cleared
Fix stale diagnostics replayed after error is resolved
Mar 24, 2026
Member
|
The common.ml change makes sense, though I'm not sure if The other part sounds like something else is wrong. |
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.
DKMissingFieldsand similar diagnostics persisted across compilations even after the underlying error was fixed, and accumulated ("stacked") with each re-run.Root cause
add_module_diagnosticandmodule_warningunconditionally wrote tom.m_extra.m_cache_bound_objects. For modules loaded from the HXB binary cache (e.g. stdlibInt/StdTypes), this DynArray is shared by reference with the binary cache entry — so each diagnostics run permanently mutated the cache.handle_cache_bound_objectsthen replayed all accumulated stale messages on every subsequent compilation.The key offender:
displayFields.ml handle_missing_field_raisecallsadd_module_diagnosticwith the target type's module (e.g.StdTypesforInt), while the message position is in the calling file. This embeds a usage-site diagnostic into a stdlib module's cache where it never belongs.Changes
add_module_diagnostic— only writes tom_cache_bound_objectswhen the message position's file matches the module's own file (msg_fkey = mod_fkey). This cleanly separates intrinsic module diagnostics (e.g. interface-complianceMissingFieldsonc.cl_module, wherec.cl_name_posis in the module's file) from usage-site diagnostics (field-access errors whose position is in the calling file, not the target type's file).module_warning— only writes tom_cache_bound_objectswhenm.m_extra.m_processed = 0, i.e. the module is freshly typed this compilation. Cached HXB modules havem_processed = old_step > 0(stored viasave_class_state+add_binary_cachein a prior compilation), so their shared DynArray is never mutated.Example
After this fix,
handle_missing_field_raiseno longer pollutesInt's cachedm_cache_bound_objects, so the diagnostic is cleared as soon as the error is gone.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.