SERVER-138281ClosedDuplicate
getType should not blindly assume FieldPath semantics for all paths
Quoting from [this thread|https://app.graphite.com/github/pr/10gen/mongo/65508#comment-PRRC_kwDOADUBOM8AAAABB5MXRA]: {quote}For example if we have: {$match: \{x: number and not array}} {$project: \{'p.a': '$x'}} Then for unknown 'p' once $project does the reshaping operation, the type of 'p' will be object or array. And the method of traversing 'p.a' (where p might be array) would be unclear. $p.a as an ExpressionFieldPath will produce a number|array, but other logic might not, and