-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Describe the bug
When declaring a file attribute, the typechecker should make sure the attribute class exists and that the constructor arguments typecheck. This check is not performed when the file does not declare any entities, or if all the declared entities are top-level constant declarations.
Standalone code, or other way to reproduce the problem
Simple case, no errors.
<<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>The file only contains constants, no errors.
<<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>
const int X = 1;
const int Y = 2;
const int Z = X + Y;The file contains a non-constant, f.e. a function, 3 errors.
<<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>
function f(): void {}Steps to reproduce the behavior:
- Typecheck the examples provided above
Expected behavior
All three cases should emit the following three errors.
Naming[2049] Unbound name: ThisDoesNotExist (an object type) [1]
bug.hack:1:9
[1] 1 | <<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>
2 | function f(): void {}
Naming[2049] Unrecognized user attribute: ThisDoesNotExist does not have a class. Please declare a class for the attribute. [1]
bug.hack:1:9
[1] 1 | <<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>
2 | function f(): void {}
Naming[2049] Unbound name: ThisIsNotBeingChecked (an object type) [1]
bug.hack:1:26
[1] 1 | <<file: ThisDoesNotExist(ThisIsNotBeingChecked::class)>>
2 | function f(): void {}
Actual behavior
Only the third case, emits errors
Environment
- Operating system
Debian GNU/Linux 12 (bookworm)
- Installation method
hhvm/hhvm on dockerhub
- HHVM Version
HipHop VM 4.168.2 (rel) (non-lowptr), hackc-af2b2722e8cac3d0bc5fe213eeb16d7296da458f-4.168.2
Additional context
This is an edge case, reported for completeness sake.