Commit 3fd4288
huangweihao
util: fix inspect crash when getter returns a function
When a property getter returns a function, formatProperty incorrectly
routes the function value to formatPrimitive, which does not handle
functions and falls through to Symbol.prototype.toString(), causing a
TypeError.
Fix by treating getter-returned functions the same as getter-returned
objects in formatProperty, routing them through formatValue which
properly formats functions.
Before (broken):
getFunction: [Getter: <Inspection threw (TypeError: ...)>]
After (fixed):
getFunction: [Getter] [Function: fn]
Fixes: #648381 parent c8e2a82 commit 3fd4288
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2576 | 2576 | | |
2577 | 2577 | | |
2578 | 2578 | | |
2579 | | - | |
| 2579 | + | |
2580 | 2580 | | |
2581 | 2581 | | |
2582 | 2582 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2596 | 2596 | | |
2597 | 2597 | | |
2598 | 2598 | | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
2599 | 2619 | | |
2600 | 2620 | | |
2601 | 2621 | | |
| |||
0 commit comments