BVB Source Codes

prettier Show Closure.js Source code

Return Download prettier: download Closure.js Source code - Download prettier Source code - Type:.js
  1. /***
  2.  * Test tracking of variable types across closure calls.
  3.  * @flow
  4.  */
  5.  
  6. function takes_string(_:string) { }
  7.  
  8. // global write from function
  9. //
  10.  
  11. var global_x = "hello";
  12.  
  13. function global_f() { }
  14. function global_g() { global_x = 42; }
  15.  
  16. global_f();
  17. takes_string(global_x); // ok
  18.  
  19. global_g();
  20. takes_string(global_x); // error
  21.  
  22. global_x = 42;  // shouldn't pollute linear refinement
  23.  
  24. // local write from function
  25. //
  26.  
  27. function local_func() {
  28.  
  29.   var local_x = "hello";
  30.  
  31.   function local_f() { }
  32.   function local_g() { local_x = 42; }
  33.  
  34.   local_f();
  35.   takes_string(local_x); // ok
  36.  
  37.   local_g();
  38.   takes_string(local_x); // error
  39.  
  40.   local_x = 42;  // shouldn't pollute linear refinement
  41. }
  42.  
  43. // global write from method
  44. //
  45.  
  46. var global_y = "hello";
  47.  
  48. var global_o = {
  49.   f: function() { },
  50.   g: function() { global_y = 42; }
  51. }
  52.  
  53. global_o.f();
  54. takes_string(global_y); // ok
  55.  
  56. global_o.g();
  57. takes_string(global_y); // error
  58.  
  59. global_y = 42;  // shouldn't pollute linear refinement
  60.  
  61. // local write from method
  62. //
  63.  
  64. function local_meth() {
  65.  
  66.   var local_y = "hello";
  67.  
  68.   var local_o = {
  69.     f: function() { },
  70.     g: function() { local_y = 42; }
  71.   }
  72.  
  73.   local_o.f();
  74.   takes_string(local_y); // ok
  75.  
  76.   local_o.g();
  77.   takes_string(local_y); // error
  78.  
  79.   local_y = 42;  // shouldn't pollute linear refinement
  80. }
  81.  
downloadClosure.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top