Annotate immediately-invoked functions for inlining flow control analysis
Per #9998 and its many offshoots, we have problems analyzing code like this ``` ts let x: string | number = "OK"; mystery(() => { x = 10; }); if (x === 10) { // Error, we believe this to be impossible } ``` The problem is that we don't know if `mystery` invokes its argument "now" or "later" (or possibly even never!). The converse problem appears during reads: ```ts let x: string | number = ...; if (typeof x === 'string') { // Error, toLowerCase doesn't exist on string | number let arr = [1, 2, 3].map(n => x.toLowerCase()); } ``` Proposal is to allow some form of indicating that the function is invoked immediately, e.g. ``` ts declare function mystery(arg: immediate () => void): void; ``` This would "inline" the function body for the purposes of flow control analysis
Posted by RyanCavanaugh on Oct 10, 2016, 7:19 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Annotate immediately-invoked functions for inlining flow control analysis
Per #9998 and its many offshoots, we have problems analyzing code like this ``` ts let x: string | number = "OK"; mystery(() => { x = 10; }); if (x === 10) { // Error, we believe this to be impossible } ``` The problem is that we don't know if `mystery` invokes its argument "now" or "later" (or possibly even never!). The converse problem appears during reads: ```ts let x: string | number = ...; if (typeof x === 'string') { // Error, toLowerCase doesn't exist on string | number let arr = [1, 2, 3].map(n => x.toLowerCase()); } ``` Proposal is to allow some form of indicating that the function is invoked immediately, e.g. ``` ts declare function mystery(arg: immediate () => void): void; ``` This would "inline" the function body for the purposes of flow control analysis
Comments (0)
No comments yet. Start the discussion.