Commit cd9835f
Fix property access on never type returning ErrorType instead of NeverType
When $case is narrowed to an impossible intersection type (e.g.
UnitEnum & BackedEnum = never), property access like $case->value
returned ErrorType. Since ErrorType extends MixedType, this corrupted
type inference in ternary expressions: union(ErrorType, string) became
mixed instead of string, causing false "invalid array key type mixed"
errors.
Now PropertyFetchHandler returns NeverType for property access on
NeverType, so union(NeverType, string) correctly simplifies to string.
Also skip InvalidComparisonOperationRule when either operand is
NeverType, since comparisons in dead code shouldn't be reported.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8f559bc commit cd9835f
2 files changed
Lines changed: 17 additions & 3 deletions
File tree
- src
- Analyser/ExprHandler
- Rules/Operators
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
111 | | - | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | | - | |
72 | | - | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
0 commit comments