Skip to content

[server] fix false module shadowing across packages#12938

Open
kLabz wants to merge 2 commits into
developmentfrom
hxb/fix-shadowing
Open

[server] fix false module shadowing across packages#12938
kLabz wants to merge 2 commits into
developmentfrom
hxb/fix-shadowing

Conversation

@kLabz

@kLabz kLabz commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

check_module_shadowing built the candidate shadow path from the module's short name only (dir/<name>.hx), ignoring its package. So a changed directory containing a same-short-named file in a different package would falsely shadow a packaged module, marking it dirty on every build and cascading to its whole dependency cone.

Only treat a changed directory as a shadow source for a module when the directory is that module's package directory (its path ends with the module's package). Root-package modules keep the previous behavior; legitimate shadowing (incl. _std overrides) is unaffected.

check_module_shadowing built the candidate shadow path from the module's
short name only (dir/<name>.hx), ignoring its package. So a changed
directory containing a same-short-named file in a *different* package
would falsely shadow a packaged module, marking it dirty on every build
and cascading to its whole dependency cone.

Only treat a changed directory as a shadow source for a module when the
directory is that module's package directory (its path ends with the
module's package). Root-package modules keep the previous behavior;
legitimate shadowing (incl. _std overrides) is unaffected.
@Simn

Simn commented Jun 10, 2026

Copy link
Copy Markdown
Member

Unfortunately I don't think that's technically correct because Haxe's imports still have that odd parent package browsing Nicolas implemented 20 years ago. If you're in module a.b.M and reference R, the compiler will look for a.b.R, a.R and R. So we have to be a bit careful here.

However, there's definitely an improvement potential because #9150 has been addressed by now, which was part of the reason why the shadowing check is so conservative.

@kLabz

kLabz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

I know but this change should only be about making a shadowed module dirty, it shouldn't get in the way of parent package browsing? (and if it did, it would likely have exploded on me already?)

Edit: hmm, I think I see what you're saying; will need to double check if that is using the "real" package for the module, and not just the name used to resolve to it

The previous fix restricted the shadow scan to the module's *exact* package
directory, which is unsound under Haxe's parent-package browsing: from a.b.X
an unqualified R resolves a.b.R > a.R > R, so a newly created deeper a.b.R
shadows the cached a.R for references made from a.b. Requiring the changed
dir to equal the module's package dir misses that and leaves dependents bound
to the stale shallower module.

Match instead when the module's package is a *prefix* of the changed dir's
package (the package dir itself or any sub-package of it). Tested textually
(prefix at path start or as a "/"-delimited sub-path) rather than by
classpath-root stripping, so a path-normalization mismatch can't become a
missed shadow; the only residual is a rare harmless over-invalidation when a
same-named package is nested under another.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants