You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject Hack files placed directly under an implicit package family path
Summary:
# Context
An implicit package family declares a `path`, and each direct child directory
`D` of that path denotes a synthesized member package `F.D`. A file sitting
directly under the family path, with no intervening directory, therefore belongs
to no member package at all.
Nothing reported that. The file simply resolved to "no package", which silently
exempts it from cross-package enforcement in both directions. It is an edge case the original design
missed rather than a decision, so it should be an error.
# Solution
Add `Naming[2135]`, raised when a file lies directly under a family `path`.
This check is done in the lowerer, which has access to the package information needed. The check is invoked from `p_script`, which runs exactly once per file before any
definition is lowered, so a file that declares nothing is still checked. It is
deliberately independent of `__PackageOverride`: an override cannot make a
badly-placed file legal.
The error is anchored at the very start of the file as a zero-width position.
Nothing the file *contains* is at fault, so there is no text worth underlining --
and a fixed-width span would be wrong for a `.hack` file, which has no `<?hh`
pragma and therefore begins with ordinary code.
Reviewed By: madgen
Differential Revision: D114385205
fbshipit-source-id: 6f15cab900cd2065f7471a95ec94420d2b0a3f15
"A Hack file cannot be placed directly under the implicit package family `{}`; move it into a subdirectory so it belongs to a member package `{}.<dir>`",
163
+
family, family
164
+
)
165
+
.into(),
166
+
),
167
+
vec![Message(
168
+
family_pos,
169
+
format!("The implicit package family `{}` is declared here", family).into(),
error: Naming[2135] A Hack file cannot be placed directly under the implicit package family `prototypes`; move it into a subdirectory so it belongs to a member package `prototypes.<dir>` [1]
2
+
-> The implicit package family `prototypes` is declared here [2]
error: Naming[2135] A Hack file cannot be placed directly under the implicit package family `prototypes`; move it into a subdirectory so it belongs to a member package `prototypes.<dir>` [1]
2
+
-> The implicit package family `prototypes` is declared here [2]
0 commit comments