diff --git a/analysis/examples/larger-project/.gitignore b/analysis/examples/larger-project/.gitignore
new file mode 100644
index 000000000..1ccc52a7f
--- /dev/null
+++ b/analysis/examples/larger-project/.gitignore
@@ -0,0 +1,2 @@
+/node_modules
+/lib
\ No newline at end of file
diff --git a/analysis/examples/larger-project/.merlin b/analysis/examples/larger-project/.merlin
new file mode 100644
index 000000000..c5130bee7
--- /dev/null
+++ b/analysis/examples/larger-project/.merlin
@@ -0,0 +1,14 @@
+####{BSB GENERATED: NO EDIT
+FLG -ppx '/Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/rescript/darwin/bsc.exe -as-ppx -bs-jsx 3'
+S /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/rescript/lib/ocaml
+B /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/rescript/lib/ocaml
+FLG -w +a-4-9-20-40-41-42-50-61-102
+S /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/@rescript/react/lib/ocaml
+B /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/@rescript/react/lib/ocaml
+S /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/@glennsl/bs-json/lib/ocaml
+B /Users/cristianocalcagno/GitHub/rescript-vscode/analysis/examples/larger-project/node_modules/@glennsl/bs-json/lib/ocaml
+S src
+B lib/bs/src
+S src/exception
+B lib/bs/src/exception
+####BSB GENERATED: NO EDIT}
diff --git a/analysis/examples/larger-project/.watchmanconfig b/analysis/examples/larger-project/.watchmanconfig
new file mode 100644
index 000000000..e69de29bb
diff --git a/analysis/examples/larger-project/bsconfig.json b/analysis/examples/larger-project/bsconfig.json
new file mode 100644
index 000000000..e3a2f6f55
--- /dev/null
+++ b/analysis/examples/larger-project/bsconfig.json
@@ -0,0 +1,21 @@
+{
+ "reanalyze": {
+ "analysis": ["dce"],
+ "suppress": [],
+ "unsuppress": []
+ },
+ "name": "sample-typescript-app",
+ "bsc-flags": ["-bs-super-errors -w a"],
+ "reason": { "react-jsx": 3 },
+ "bs-dependencies": ["@rescript/react", "@glennsl/bs-json"],
+ "sources": [
+ {
+ "dir": "src",
+ "subdirs": true
+ }
+ ],
+ "package-specs": {
+ "module": "es6",
+ "in-source": true
+ }
+}
diff --git a/analysis/examples/larger-project/package-lock.json b/analysis/examples/larger-project/package-lock.json
new file mode 100644
index 000000000..8747db2f2
--- /dev/null
+++ b/analysis/examples/larger-project/package-lock.json
@@ -0,0 +1,192 @@
+{
+ "name": "large-project",
+ "version": "0.1.0",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "large-project",
+ "version": "0.1.0",
+ "dependencies": {
+ "@glennsl/bs-json": "^5.0.4",
+ "@rescript/react": "^0.10.3"
+ },
+ "devDependencies": {
+ "react": "^16.13.1",
+ "react-dom": "^16.8.6",
+ "rescript": "^9.1.4"
+ }
+ },
+ "../../../../../rescript-compiler": {
+ "name": "rescript",
+ "version": "10.0.0",
+ "extraneous": true,
+ "hasInstallScript": true,
+ "license": "SEE LICENSE IN LICENSE",
+ "bin": {
+ "bsc": "bsc",
+ "bsrefmt": "bsrefmt",
+ "bstracing": "lib/bstracing",
+ "rescript": "rescript"
+ },
+ "devDependencies": {
+ "mocha": "^7.2.0",
+ "nyc": "^15.0.0"
+ }
+ },
+ "node_modules/@glennsl/bs-json": {
+ "version": "5.0.4",
+ "license": "(LGPL-3.0 OR MPL-2.0)"
+ },
+ "node_modules/@rescript/react": {
+ "version": "0.10.3",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": ">=16.8.1",
+ "react-dom": ">=16.8.1"
+ }
+ },
+ "node_modules/js-tokens": {
+ "version": "4.0.0",
+ "license": "MIT"
+ },
+ "node_modules/loose-envify": {
+ "version": "1.4.0",
+ "license": "MIT",
+ "dependencies": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ },
+ "bin": {
+ "loose-envify": "cli.js"
+ }
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/prop-types": {
+ "version": "15.8.1",
+ "license": "MIT",
+ "dependencies": {
+ "loose-envify": "^1.4.0",
+ "object-assign": "^4.1.1",
+ "react-is": "^16.13.1"
+ }
+ },
+ "node_modules/react": {
+ "version": "16.14.0",
+ "license": "MIT",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "prop-types": "^15.6.2"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/react-dom": {
+ "version": "16.14.0",
+ "license": "MIT",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "prop-types": "^15.6.2",
+ "scheduler": "^0.19.1"
+ },
+ "peerDependencies": {
+ "react": "^16.14.0"
+ }
+ },
+ "node_modules/react-is": {
+ "version": "16.13.1",
+ "license": "MIT"
+ },
+ "node_modules/rescript": {
+ "version": "9.1.4",
+ "resolved": "https://registry.npmjs.org/rescript/-/rescript-9.1.4.tgz",
+ "integrity": "sha512-aXANK4IqecJzdnDpJUsU6pxMViCR5ogAxzuqS0mOr8TloMnzAjJFu63fjD6LCkWrKAhlMkFFzQvVQYaAaVkFXw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "bin": {
+ "bsc": "bsc",
+ "bsrefmt": "bsrefmt",
+ "bstracing": "lib/bstracing",
+ "rescript": "rescript"
+ }
+ },
+ "node_modules/scheduler": {
+ "version": "0.19.1",
+ "license": "MIT",
+ "dependencies": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ }
+ },
+ "dependencies": {
+ "@glennsl/bs-json": {
+ "version": "5.0.4"
+ },
+ "@rescript/react": {
+ "version": "0.10.3",
+ "requires": {}
+ },
+ "js-tokens": {
+ "version": "4.0.0"
+ },
+ "loose-envify": {
+ "version": "1.4.0",
+ "requires": {
+ "js-tokens": "^3.0.0 || ^4.0.0"
+ }
+ },
+ "object-assign": {
+ "version": "4.1.1"
+ },
+ "prop-types": {
+ "version": "15.8.1",
+ "requires": {
+ "loose-envify": "^1.4.0",
+ "object-assign": "^4.1.1",
+ "react-is": "^16.13.1"
+ }
+ },
+ "react": {
+ "version": "16.14.0",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "prop-types": "^15.6.2"
+ }
+ },
+ "react-dom": {
+ "version": "16.14.0",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1",
+ "prop-types": "^15.6.2",
+ "scheduler": "^0.19.1"
+ }
+ },
+ "react-is": {
+ "version": "16.13.1"
+ },
+ "rescript": {
+ "version": "9.1.4",
+ "resolved": "https://registry.npmjs.org/rescript/-/rescript-9.1.4.tgz",
+ "integrity": "sha512-aXANK4IqecJzdnDpJUsU6pxMViCR5ogAxzuqS0mOr8TloMnzAjJFu63fjD6LCkWrKAhlMkFFzQvVQYaAaVkFXw==",
+ "dev": true
+ },
+ "scheduler": {
+ "version": "0.19.1",
+ "requires": {
+ "loose-envify": "^1.1.0",
+ "object-assign": "^4.1.1"
+ }
+ }
+ }
+}
diff --git a/analysis/examples/larger-project/package.json b/analysis/examples/larger-project/package.json
new file mode 100644
index 000000000..1426ee18c
--- /dev/null
+++ b/analysis/examples/larger-project/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "large-project",
+ "version": "0.1.0",
+ "private": true,
+ "scripts": {
+ "start": "rescript build -w",
+ "build": "rescript build",
+ "clean": "rescript clean -with-deps"
+ },
+ "devDependencies": {
+ "react": "^16.13.1",
+ "react-dom": "^16.8.6",
+ "rescript": "^9.1.4"
+ },
+ "dependencies": {
+ "@glennsl/bs-json": "^5.0.4",
+ "@rescript/react": "^0.10.3"
+ }
+}
diff --git a/analysis/examples/larger-project/src/AutoAnnotate.js b/analysis/examples/larger-project/src/AutoAnnotate.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/AutoAnnotate.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/AutoAnnotate.res b/analysis/examples/larger-project/src/AutoAnnotate.res
new file mode 100644
index 000000000..71f125728
--- /dev/null
+++ b/analysis/examples/larger-project/src/AutoAnnotate.res
@@ -0,0 +1,15 @@
+type variant = R(int)
+
+@genType
+type record = {variant: variant}
+
+type r2 = {r2: int}
+
+type r3 = {r3: int}
+
+type r4 = {r4: int}
+
+@genType
+type annotatedVariant =
+ | R2(r2, r3)
+ | R4(r4)
diff --git a/analysis/examples/larger-project/src/BootloaderResource.js b/analysis/examples/larger-project/src/BootloaderResource.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/BootloaderResource.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/BootloaderResource.res b/analysis/examples/larger-project/src/BootloaderResource.res
new file mode 100644
index 000000000..a21560764
--- /dev/null
+++ b/analysis/examples/larger-project/src/BootloaderResource.res
@@ -0,0 +1,4 @@
+/* NOTE: This is a spooky interface that provides no type safety. It should be
+ * improved. Use with caution. */
+@module("BootloaderResource")
+external read: JSResource.t<'a> => 'a = "read"
diff --git a/analysis/examples/larger-project/src/BucklescriptAnnotations.js b/analysis/examples/larger-project/src/BucklescriptAnnotations.js
new file mode 100644
index 000000000..7dab449cd
--- /dev/null
+++ b/analysis/examples/larger-project/src/BucklescriptAnnotations.js
@@ -0,0 +1,13 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function bar(x) {
+ var f = x.twoArgs;
+ return f(3, "a");
+}
+
+export {
+ bar ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/BucklescriptAnnotations.res b/analysis/examples/larger-project/src/BucklescriptAnnotations.res
new file mode 100644
index 000000000..053bca66b
--- /dev/null
+++ b/analysis/examples/larger-project/src/BucklescriptAnnotations.res
@@ -0,0 +1,28 @@
+@genType
+type someMutableFields = {
+ @set
+ "mutable0": string,
+ "immutable": int,
+ @set
+ "mutable1": string,
+ @set
+ "mutable2": string,
+}
+
+@genType
+type someMethods = {
+ @meth
+ "send": string => unit,
+ @meth
+ "on": (string, (. int) => unit) => unit,
+ @meth
+ "threeargs": (int, string, int) => string,
+ "twoArgs": (. int, string) => int,
+}
+
+// let foo = (x: someMethods) => x["threeargs"](3, "a", 4)
+
+let bar = (x: someMethods) => {
+ let f = x["twoArgs"]
+ f(. 3, "a")
+}
diff --git a/analysis/examples/larger-project/src/ComponentAsProp.js b/analysis/examples/larger-project/src/ComponentAsProp.js
new file mode 100644
index 000000000..f3eba08a7
--- /dev/null
+++ b/analysis/examples/larger-project/src/ComponentAsProp.js
@@ -0,0 +1,19 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as React from "react";
+import * as Caml_option from "rescript/lib/es6/caml_option.js";
+
+function ComponentAsProp(Props) {
+ var title = Props.title;
+ var description = Props.description;
+ var button = Props.button;
+ return React.createElement("div", undefined, React.createElement("div", undefined, title, description, button !== undefined ? Caml_option.valFromOption(button) : null));
+}
+
+var make = ComponentAsProp;
+
+export {
+ make ,
+
+}
+/* react Not a pure module */
diff --git a/analysis/examples/larger-project/src/ComponentAsProp.res b/analysis/examples/larger-project/src/ComponentAsProp.res
new file mode 100644
index 000000000..a1f3d4565
--- /dev/null
+++ b/analysis/examples/larger-project/src/ComponentAsProp.res
@@ -0,0 +1,17 @@
+@ocaml.doc(
+ " This is like declaring a normal ReasonReact component's `make` function, except the body is a the interop hook wrapJsForReason "
+)
+@genType
+@react.component
+let make = (~title, ~description, ~button=?) => {
+
+
+ title
+ description
+ {switch button {
+ | Some(button) => button
+ | None => React.null
+ }}
+
+
+}
diff --git a/analysis/examples/larger-project/src/CreateErrorHandler1.js b/analysis/examples/larger-project/src/CreateErrorHandler1.js
new file mode 100644
index 000000000..6adeaad3f
--- /dev/null
+++ b/analysis/examples/larger-project/src/CreateErrorHandler1.js
@@ -0,0 +1,26 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Curry from "rescript/lib/es6/curry.js";
+import * as ErrorHandler from "./ErrorHandler.js";
+
+function notification(s) {
+ return [
+ s,
+ s
+ ];
+}
+
+var Error1 = {
+ notification: notification
+};
+
+var MyErrorHandler = ErrorHandler.Make(Error1);
+
+Curry._1(MyErrorHandler.notify, "abc");
+
+export {
+ Error1 ,
+ MyErrorHandler ,
+
+}
+/* MyErrorHandler Not a pure module */
diff --git a/analysis/examples/larger-project/src/CreateErrorHandler1.res b/analysis/examples/larger-project/src/CreateErrorHandler1.res
new file mode 100644
index 000000000..e10b58c1d
--- /dev/null
+++ b/analysis/examples/larger-project/src/CreateErrorHandler1.res
@@ -0,0 +1,8 @@
+module Error1 = {
+ type t = string
+ let notification = s => (s, s)
+}
+
+module MyErrorHandler = ErrorHandler.Make(Error1)
+
+MyErrorHandler.notify("abc")
diff --git a/analysis/examples/larger-project/src/CreateErrorHandler2.js b/analysis/examples/larger-project/src/CreateErrorHandler2.js
new file mode 100644
index 000000000..6855cbd83
--- /dev/null
+++ b/analysis/examples/larger-project/src/CreateErrorHandler2.js
@@ -0,0 +1,23 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as ErrorHandler from "./ErrorHandler.js";
+
+function notification(n) {
+ return [
+ String(n),
+ ""
+ ];
+}
+
+var Error2 = {
+ notification: notification
+};
+
+var MyErrorHandler = ErrorHandler.Make(Error2);
+
+export {
+ Error2 ,
+ MyErrorHandler ,
+
+}
+/* MyErrorHandler Not a pure module */
diff --git a/analysis/examples/larger-project/src/CreateErrorHandler2.res b/analysis/examples/larger-project/src/CreateErrorHandler2.res
new file mode 100644
index 000000000..394907545
--- /dev/null
+++ b/analysis/examples/larger-project/src/CreateErrorHandler2.res
@@ -0,0 +1,6 @@
+module Error2 = {
+ type t = int
+ let notification = n => (string_of_int(n), "")
+}
+
+module MyErrorHandler = ErrorHandler.Make(Error2) /* MyErrorHandler.notify(42) */
diff --git a/analysis/examples/larger-project/src/DeadCodeImplementation.js b/analysis/examples/larger-project/src/DeadCodeImplementation.js
new file mode 100644
index 000000000..457027834
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadCodeImplementation.js
@@ -0,0 +1,12 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var M = {
+ x: 42
+};
+
+export {
+ M ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/DeadCodeImplementation.res b/analysis/examples/larger-project/src/DeadCodeImplementation.res
new file mode 100644
index 000000000..54abe4ead
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadCodeImplementation.res
@@ -0,0 +1,3 @@
+module M: DeadCodeInterface.T = {
+ let x = 42
+}
diff --git a/analysis/examples/larger-project/src/DeadCodeInterface.js b/analysis/examples/larger-project/src/DeadCodeInterface.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadCodeInterface.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/DeadCodeInterface.res b/analysis/examples/larger-project/src/DeadCodeInterface.res
new file mode 100644
index 000000000..069bea77a
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadCodeInterface.res
@@ -0,0 +1,3 @@
+module type T = {
+ let x: int
+}
diff --git a/analysis/examples/larger-project/src/DeadExn.js b/analysis/examples/larger-project/src/DeadExn.js
new file mode 100644
index 000000000..c2a21594d
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadExn.js
@@ -0,0 +1,19 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
+
+var Etoplevel = /* @__PURE__ */Caml_exceptions.create("DeadExn.Etoplevel");
+
+var Einside = /* @__PURE__ */Caml_exceptions.create("DeadExn.Inside.Einside");
+
+var eInside = {
+ RE_EXN_ID: Einside
+};
+
+console.log(eInside);
+
+export {
+ Etoplevel ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/DeadExn.res b/analysis/examples/larger-project/src/DeadExn.res
new file mode 100644
index 000000000..a515033a0
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadExn.res
@@ -0,0 +1,12 @@
+exception Etoplevel
+
+module Inside = {
+ exception Einside
+}
+
+exception DeadE
+let eToplevel = Etoplevel
+
+let eInside = Inside.Einside
+
+Js.log(eInside)
diff --git a/analysis/examples/larger-project/src/DeadExn.resi b/analysis/examples/larger-project/src/DeadExn.resi
new file mode 100644
index 000000000..168689421
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadExn.resi
@@ -0,0 +1,2 @@
+// empty
+exception Etoplevel
diff --git a/analysis/examples/larger-project/src/DeadRT.js b/analysis/examples/larger-project/src/DeadRT.js
new file mode 100644
index 000000000..028c363b5
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadRT.js
@@ -0,0 +1,9 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+console.log(/* Kaboom */0);
+
+export {
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/DeadRT.res b/analysis/examples/larger-project/src/DeadRT.res
new file mode 100644
index 000000000..1ebbc4c32
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadRT.res
@@ -0,0 +1,11 @@
+type moduleAccessPath =
+ | Root(string)
+ | Kaboom
+
+let rec emitModuleAccessPath = moduleAccessPath =>
+ switch moduleAccessPath {
+ | Root(s) => s
+ | Kaboom => ""
+ }
+
+let () = Js.log(Kaboom)
diff --git a/analysis/examples/larger-project/src/DeadRT.resi b/analysis/examples/larger-project/src/DeadRT.resi
new file mode 100644
index 000000000..123cd38f6
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadRT.resi
@@ -0,0 +1,3 @@
+type moduleAccessPath =
+ | Root(string)
+ | Kaboom
diff --git a/analysis/examples/larger-project/src/DeadTest.js b/analysis/examples/larger-project/src/DeadTest.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTest.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/DeadTest.res b/analysis/examples/larger-project/src/DeadTest.res
new file mode 100644
index 000000000..e69de29bb
diff --git a/analysis/examples/larger-project/src/DeadTestBlacklist.js b/analysis/examples/larger-project/src/DeadTestBlacklist.js
new file mode 100644
index 000000000..9a29139bd
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTestBlacklist.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var x = 34;
+
+export {
+ x ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/DeadTestBlacklist.res b/analysis/examples/larger-project/src/DeadTestBlacklist.res
new file mode 100644
index 000000000..5681c08c6
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTestBlacklist.res
@@ -0,0 +1 @@
+let x = 34
diff --git a/analysis/examples/larger-project/src/DeadTestWithInterface.js b/analysis/examples/larger-project/src/DeadTestWithInterface.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTestWithInterface.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/DeadTestWithInterface.res b/analysis/examples/larger-project/src/DeadTestWithInterface.res
new file mode 100644
index 000000000..4d50cd03f
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTestWithInterface.res
@@ -0,0 +1,5 @@
+module Ext_buffer: {
+ let x: int
+} = {
+ let x = 42
+}
diff --git a/analysis/examples/larger-project/src/DeadTestWithInterface.resi b/analysis/examples/larger-project/src/DeadTestWithInterface.resi
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTestWithInterface.resi
@@ -0,0 +1 @@
+
diff --git a/analysis/examples/larger-project/src/DeadTypeTest.js b/analysis/examples/larger-project/src/DeadTypeTest.js
new file mode 100644
index 000000000..9740261e3
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTypeTest.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var a = /* A */0;
+
+export {
+ a ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/DeadTypeTest.res b/analysis/examples/larger-project/src/DeadTypeTest.res
new file mode 100644
index 000000000..6b70da554
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTypeTest.res
@@ -0,0 +1,16 @@
+type t =
+ | A
+ | B
+let a = A
+
+type deadType =
+ | OnlyInImplementation
+ | OnlyInInterface
+ | InBoth
+ | InNeither
+
+let _ = OnlyInImplementation
+let _ = InBoth
+
+@live
+type record = {x: int, y: string, z: float}
diff --git a/analysis/examples/larger-project/src/DeadTypeTest.resi b/analysis/examples/larger-project/src/DeadTypeTest.resi
new file mode 100644
index 000000000..317bc02c1
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadTypeTest.resi
@@ -0,0 +1,10 @@
+type t =
+ | A
+ | B
+let a: t
+
+type deadType =
+ | OnlyInImplementation
+ | OnlyInInterface
+ | InBoth
+ | InNeither
diff --git a/analysis/examples/larger-project/src/DeadValueTest.js b/analysis/examples/larger-project/src/DeadValueTest.js
new file mode 100644
index 000000000..2b37b2ec1
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadValueTest.js
@@ -0,0 +1,13 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var valueAlive = 1;
+
+var valueDead = 2;
+
+export {
+ valueAlive ,
+ valueDead ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/DeadValueTest.res b/analysis/examples/larger-project/src/DeadValueTest.res
new file mode 100644
index 000000000..a3fd03b6f
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadValueTest.res
@@ -0,0 +1,21 @@
+let valueAlive = 1
+let valueDead = 2
+
+let valueOnlyInImplementation = 3
+
+@raises(Failure)
+let rec subList = (b, e, l) =>
+ switch l {
+ | list{} => failwith("subList")
+ | list{h, ...t} =>
+ let tail = if e == 0 {
+ list{}
+ } else {
+ subList(b - 1, e - 1, t)
+ }
+ if b > 0 {
+ tail
+ } else {
+ list{h, ...tail}
+ }
+ }
diff --git a/analysis/examples/larger-project/src/DeadValueTest.resi b/analysis/examples/larger-project/src/DeadValueTest.resi
new file mode 100644
index 000000000..4f6bb0cc2
--- /dev/null
+++ b/analysis/examples/larger-project/src/DeadValueTest.resi
@@ -0,0 +1,2 @@
+let valueAlive: int
+let valueDead: int
diff --git a/analysis/examples/larger-project/src/Docstrings.js b/analysis/examples/larger-project/src/Docstrings.js
new file mode 100644
index 000000000..e06b04eb7
--- /dev/null
+++ b/analysis/examples/larger-project/src/Docstrings.js
@@ -0,0 +1,100 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function signMessage(message, key) {
+ return message + String(key);
+}
+
+function one(a) {
+ return a + 0 | 0;
+}
+
+function two(a, b) {
+ return (a + b | 0) + 0 | 0;
+}
+
+function tree(a, b, c) {
+ return ((a + b | 0) + c | 0) + 0 | 0;
+}
+
+function oneU(a) {
+ return a + 0 | 0;
+}
+
+function twoU(a, b) {
+ return (a + b | 0) + 0 | 0;
+}
+
+function treeU(a, b, c) {
+ return ((a + b | 0) + c | 0) + 0 | 0;
+}
+
+function useParam(param) {
+ return param + 34 | 0;
+}
+
+function useParamU(param) {
+ return param + 34 | 0;
+}
+
+function unnamed1(param) {
+ return 34;
+}
+
+function unnamed1U(param) {
+ return 34;
+}
+
+function unnamed2(param, param$1) {
+ return 34;
+}
+
+function unnamed2U(param, param$1) {
+ return 34;
+}
+
+function grouped(x, y, a, b, c, z) {
+ return ((((x + y | 0) + a | 0) + b | 0) + c | 0) + z | 0;
+}
+
+function unitArgWithoutConversion(param) {
+ return "abc";
+}
+
+function unitArgWithoutConversionU() {
+ return "abc";
+}
+
+function unitArgWithConversion(param) {
+ return /* A */0;
+}
+
+function unitArgWithConversionU() {
+ return /* A */0;
+}
+
+var flat = 34;
+
+export {
+ flat ,
+ signMessage ,
+ one ,
+ two ,
+ tree ,
+ oneU ,
+ twoU ,
+ treeU ,
+ useParam ,
+ useParamU ,
+ unnamed1 ,
+ unnamed1U ,
+ unnamed2 ,
+ unnamed2U ,
+ grouped ,
+ unitArgWithoutConversion ,
+ unitArgWithoutConversionU ,
+ unitArgWithConversion ,
+ unitArgWithConversionU ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Docstrings.res b/analysis/examples/larger-project/src/Docstrings.res
new file mode 100644
index 000000000..ca3d7ee03
--- /dev/null
+++ b/analysis/examples/larger-project/src/Docstrings.res
@@ -0,0 +1,67 @@
+@ocaml.doc(" hello ") @genType
+let flat = 34
+
+@ocaml.doc("
+ * Sign a message with a key.
+ *
+ * @param message - A message to be signed
+ * @param key - The key with which to sign the message
+ * @returns A signed message
+ ")
+@genType
+let signMessage = (. message, key) => message ++ string_of_int(key)
+
+@genType
+let one = a => a + 0
+
+@genType
+let two = (a, b) => a + b + 0
+
+@genType
+let tree = (a, b, c) => a + b + c + 0
+
+@genType
+let oneU = (. a) => a + 0
+
+@genType
+let twoU = (. a, b) => a + b + 0
+
+@genType
+let treeU = (. a, b, c) => a + b + c + 0
+
+@genType
+let useParam = param => param + 34
+
+@genType
+let useParamU = (. param) => param + 34
+
+@genType
+let unnamed1 = (_: int) => 34
+
+@genType
+let unnamed1U = (. _: int) => 34
+
+@genType
+let unnamed2 = (_: int, _: int) => 34
+
+@genType
+let unnamed2U = (. _: int, _: int) => 34
+
+@genType
+let grouped = (~x, ~y, a, b, c, ~z) => x + y + a + b + c + z
+
+@genType
+let unitArgWithoutConversion = () => "abc"
+
+@genType
+let unitArgWithoutConversionU = (. ()) => "abc"
+
+type t =
+ | A
+ | B
+
+@genType
+let unitArgWithConversion = () => A
+
+@genType
+let unitArgWithConversionU = (. ()) => A
diff --git a/analysis/examples/larger-project/src/DynamicallyLoadedComponent.js b/analysis/examples/larger-project/src/DynamicallyLoadedComponent.js
new file mode 100644
index 000000000..984fa357b
--- /dev/null
+++ b/analysis/examples/larger-project/src/DynamicallyLoadedComponent.js
@@ -0,0 +1,14 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function DynamicallyLoadedComponent(Props) {
+ return Props.s;
+}
+
+var make = DynamicallyLoadedComponent;
+
+export {
+ make ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/DynamicallyLoadedComponent.res b/analysis/examples/larger-project/src/DynamicallyLoadedComponent.res
new file mode 100644
index 000000000..b7b93b52c
--- /dev/null
+++ b/analysis/examples/larger-project/src/DynamicallyLoadedComponent.res
@@ -0,0 +1,2 @@
+@react.component
+let make = (~s) => React.string(s)
diff --git a/analysis/examples/larger-project/src/EmptyArray.js b/analysis/examples/larger-project/src/EmptyArray.js
new file mode 100644
index 000000000..6e55be63a
--- /dev/null
+++ b/analysis/examples/larger-project/src/EmptyArray.js
@@ -0,0 +1,19 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as React from "react";
+
+function EmptyArray$Z(Props) {
+ return React.createElement("br", undefined);
+}
+
+var Z = {
+ make: EmptyArray$Z
+};
+
+React.createElement(EmptyArray$Z, {});
+
+export {
+ Z ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/EmptyArray.res b/analysis/examples/larger-project/src/EmptyArray.res
new file mode 100644
index 000000000..9c44bd9a7
--- /dev/null
+++ b/analysis/examples/larger-project/src/EmptyArray.res
@@ -0,0 +1,10 @@
+// @@config({flags : ["-dsource"]});
+
+module Z = {
+ @react.component
+ let make = () => {
+
+ }
+}
+
+let _ =
diff --git a/analysis/examples/larger-project/src/ErrorHandler.js b/analysis/examples/larger-project/src/ErrorHandler.js
new file mode 100644
index 000000000..b79220461
--- /dev/null
+++ b/analysis/examples/larger-project/src/ErrorHandler.js
@@ -0,0 +1,21 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Curry from "rescript/lib/es6/curry.js";
+
+function Make($$Error) {
+ var notify = function (x) {
+ return Curry._1($$Error.notification, x);
+ };
+ return {
+ notify: notify
+ };
+}
+
+var x = 42;
+
+export {
+ Make ,
+ x ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/ErrorHandler.res b/analysis/examples/larger-project/src/ErrorHandler.res
new file mode 100644
index 000000000..557272ca1
--- /dev/null
+++ b/analysis/examples/larger-project/src/ErrorHandler.res
@@ -0,0 +1,12 @@
+module type Error = {
+ type t
+ let notification: t => (string, string)
+}
+
+module Make = (Error: Error) => {
+ let notify = x => Error.notification(x)
+}
+
+// This is ignored as there's an interface file
+@genType
+let x = 42
diff --git a/analysis/examples/larger-project/src/ErrorHandler.resi b/analysis/examples/larger-project/src/ErrorHandler.resi
new file mode 100644
index 000000000..fac11f751
--- /dev/null
+++ b/analysis/examples/larger-project/src/ErrorHandler.resi
@@ -0,0 +1,10 @@
+module type Error = {
+ type t
+ let notification: t => (string, string)
+}
+module Make: (Error: Error) =>
+{
+ let notify: Error.t => (string, string)
+}
+
+let x: int
diff --git a/analysis/examples/larger-project/src/EverythingLiveHere.js b/analysis/examples/larger-project/src/EverythingLiveHere.js
new file mode 100644
index 000000000..864f5020e
--- /dev/null
+++ b/analysis/examples/larger-project/src/EverythingLiveHere.js
@@ -0,0 +1,16 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var x = 1;
+
+var y = 3;
+
+var z = 4;
+
+export {
+ x ,
+ y ,
+ z ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/EverythingLiveHere.res b/analysis/examples/larger-project/src/EverythingLiveHere.res
new file mode 100644
index 000000000..86ff46d5c
--- /dev/null
+++ b/analysis/examples/larger-project/src/EverythingLiveHere.res
@@ -0,0 +1,5 @@
+let x = 1
+
+let y = 3
+
+let z = 4
diff --git a/analysis/examples/larger-project/src/FC.js b/analysis/examples/larger-project/src/FC.js
new file mode 100644
index 000000000..1beb8f443
--- /dev/null
+++ b/analysis/examples/larger-project/src/FC.js
@@ -0,0 +1,14 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function foo(impl) {
+ return impl.make;
+}
+
+console.log(foo);
+
+export {
+ foo ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/FC.res b/analysis/examples/larger-project/src/FC.res
new file mode 100644
index 000000000..6a55ba0a2
--- /dev/null
+++ b/analysis/examples/larger-project/src/FC.res
@@ -0,0 +1,11 @@
+module type ReplacebleComponent = {
+ @react.component
+ let make: unit => React.element
+}
+
+let foo = (~impl: module(ReplacebleComponent)) => {
+ let module(X) = impl
+ X.make
+}
+
+Js.log(foo)
diff --git a/analysis/examples/larger-project/src/FirstClassModules.js b/analysis/examples/larger-project/src/FirstClassModules.js
new file mode 100644
index 000000000..d83705e55
--- /dev/null
+++ b/analysis/examples/larger-project/src/FirstClassModules.js
@@ -0,0 +1,69 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var y = "abc";
+
+var EmptyInnerModule = {};
+
+var InnerModule2 = {
+ k: 4242
+};
+
+function k3(x) {
+ return x + 1 | 0;
+}
+
+var InnerModule3 = {
+ k3: k3
+};
+
+var Z = {
+ u: [
+ 0,
+ 0
+ ]
+};
+
+var M = {
+ y: y,
+ EmptyInnerModule: EmptyInnerModule,
+ InnerModule2: InnerModule2,
+ InnerModule3: InnerModule3,
+ Z: Z,
+ x: 42
+};
+
+var firstClassModule = {
+ x: 42,
+ EmptyInnerModule: EmptyInnerModule,
+ InnerModule2: InnerModule2,
+ InnerModule3: InnerModule3,
+ Z: Z,
+ y: y
+};
+
+function testConvert(m) {
+ return m;
+}
+
+function SomeFunctor(X) {
+ return {
+ ww: X.y
+ };
+}
+
+function someFunctorAsFunction(x) {
+ return {
+ ww: x.y
+ };
+}
+
+export {
+ M ,
+ firstClassModule ,
+ testConvert ,
+ SomeFunctor ,
+ someFunctorAsFunction ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/FirstClassModules.res b/analysis/examples/larger-project/src/FirstClassModules.res
new file mode 100644
index 000000000..674d243e3
--- /dev/null
+++ b/analysis/examples/larger-project/src/FirstClassModules.res
@@ -0,0 +1,65 @@
+module type MT = {
+ let x: int
+ type t = int
+ @module("foo") external f: int => int = "f"
+ module type MT2 = {
+ type tt = string
+ }
+ module EmptyInnerModule: {}
+ module InnerModule2: {
+ let k: t
+ }
+ module InnerModule3: {
+ type inner = int
+ let k3: inner => inner
+ }
+ module type TT = {
+ let u: (int, int)
+ }
+ module Z: TT
+ let y: string
+}
+module M = {
+ let y = "abc"
+ module type MT2 = {
+ type tt = string
+ }
+ module EmptyInnerModule = {}
+ module InnerModule2 = {
+ let k = 4242
+ }
+ module InnerModule3 = {
+ type inner = int
+ let k3 = x => x + 1
+ }
+
+ module type TT = {
+ let u: (int, int)
+ }
+ module Z = {
+ let u = (0, 0)
+ }
+ type t = int
+ @module("foo") external f: int => int = "f"
+ let x = 42
+}
+
+@genType
+type firstClassModule = module(MT)
+
+@genType
+let firstClassModule: firstClassModule = module(M)
+
+@genType
+let testConvert = (m: module(MT)) => m
+
+module type ResT = {
+ let ww: string
+}
+
+module SomeFunctor = (X: MT): ResT => {
+ let ww = X.y
+}
+
+@genType
+let someFunctorAsFunction = (x: module(MT)): module(ResT) => module(SomeFunctor(unpack(x)))
diff --git a/analysis/examples/larger-project/src/FirstClassModulesInterface.js b/analysis/examples/larger-project/src/FirstClassModulesInterface.js
new file mode 100644
index 000000000..56783f6a4
--- /dev/null
+++ b/analysis/examples/larger-project/src/FirstClassModulesInterface.js
@@ -0,0 +1,13 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var r = {
+ x: 3,
+ y: "hello"
+};
+
+export {
+ r ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/FirstClassModulesInterface.res b/analysis/examples/larger-project/src/FirstClassModulesInterface.res
new file mode 100644
index 000000000..9dd75a90b
--- /dev/null
+++ b/analysis/examples/larger-project/src/FirstClassModulesInterface.res
@@ -0,0 +1,12 @@
+type record = {
+ x: int,
+ y: string,
+}
+
+let r = {x: 3, y: "hello"}
+
+module type MT = {
+ let x: int
+}
+
+type firstClassModule = module(MT)
diff --git a/analysis/examples/larger-project/src/FirstClassModulesInterface.resi b/analysis/examples/larger-project/src/FirstClassModulesInterface.resi
new file mode 100644
index 000000000..658663cc4
--- /dev/null
+++ b/analysis/examples/larger-project/src/FirstClassModulesInterface.resi
@@ -0,0 +1,15 @@
+@genType
+type record = {
+ x: int,
+ y: string,
+}
+
+let r: record
+
+@genType
+module type MT = {
+ let x: int
+}
+
+@genType
+type firstClassModule = module(MT)
diff --git a/analysis/examples/larger-project/src/Hooks.js b/analysis/examples/larger-project/src/Hooks.js
new file mode 100644
index 000000000..8b249e521
--- /dev/null
+++ b/analysis/examples/larger-project/src/Hooks.js
@@ -0,0 +1,188 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Curry from "rescript/lib/es6/curry.js";
+import * as React from "react";
+import * as ImportHooks from "./ImportHooks.js";
+import * as ImportHookDefault from "./ImportHookDefault.js";
+
+function Hooks(Props) {
+ var vehicle = Props.vehicle;
+ var match = React.useState(function () {
+ return 0;
+ });
+ var setCount = match[1];
+ var count = match[0];
+ return React.createElement("div", undefined, React.createElement("p", undefined, "Hooks example " + (vehicle.name + (" clicked " + (String(count) + " times")))), React.createElement("button", {
+ onClick: (function (param) {
+ return Curry._1(setCount, (function (param) {
+ return count + 1 | 0;
+ }));
+ })
+ }, "Click me"), React.createElement(ImportHooks.make, {
+ person: {
+ name: "Mary",
+ age: 71
+ },
+ children: null,
+ renderMe: (function (x) {
+ return x.randomString;
+ })
+ }, "child1", "child2"), React.createElement(ImportHookDefault.make, {
+ person: {
+ name: "DefaultImport",
+ age: 42
+ },
+ children: null,
+ renderMe: (function (x) {
+ return x.randomString;
+ })
+ }, "child1", "child2"));
+}
+
+function Hooks$anotherComponent(Props) {
+ var vehicle = Props.vehicle;
+ var callback = Props.callback;
+ Curry._1(callback, undefined);
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name);
+}
+
+function Hooks$Inner(Props) {
+ var vehicle = Props.vehicle;
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name);
+}
+
+function Hooks$Inner$anotherComponent(Props) {
+ var vehicle = Props.vehicle;
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name);
+}
+
+function Hooks$Inner$Inner2(Props) {
+ var vehicle = Props.vehicle;
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name);
+}
+
+function Hooks$Inner$Inner2$anotherComponent(Props) {
+ var vehicle = Props.vehicle;
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name);
+}
+
+var Inner2 = {
+ make: Hooks$Inner$Inner2,
+ anotherComponent: Hooks$Inner$Inner2$anotherComponent
+};
+
+var Inner = {
+ make: Hooks$Inner,
+ anotherComponent: Hooks$Inner$anotherComponent,
+ Inner2: Inner2
+};
+
+function Hooks$NoProps(Props) {
+ return React.createElement("div", undefined, null);
+}
+
+var NoProps = {
+ make: Hooks$NoProps
+};
+
+function functionWithRenamedArgs(_to, _Type, cb) {
+ Curry._1(cb, _to);
+ return _to.name + _Type.name;
+}
+
+function Hooks$componentWithRenamedArgs(Props) {
+ var _to = Props.to;
+ var _Type = Props.Type;
+ var cb = Props.cb;
+ Curry._1(cb, _to);
+ return _to.name + _Type.name;
+}
+
+function Hooks$makeWithRef(Props) {
+ var vehicle = Props.vehicle;
+ return function (ref) {
+ if (ref == null) {
+ return null;
+ } else {
+ return React.createElement("button", {
+ ref: ref
+ }, vehicle.name);
+ }
+ };
+}
+
+var testForwardRef = React.forwardRef(function (param, param$1) {
+ return Hooks$makeWithRef(param)(param$1);
+ });
+
+var input = React.forwardRef(function (Props, param) {
+ var partial_arg = Props.r;
+ return React.createElement("div", {
+ ref: param
+ }, partial_arg.x);
+ });
+
+function Hooks$polymorphicComponent(Props) {
+ var param = Props.p;
+ return param[0].name;
+}
+
+function Hooks$functionReturningReactElement(Props) {
+ return Props.name;
+}
+
+function Hooks$RenderPropRequiresConversion(Props) {
+ var renderVehicle = Props.renderVehicle;
+ return Curry._1(renderVehicle, {
+ vehicle: {
+ name: "Car"
+ },
+ number: 42
+ });
+}
+
+var RenderPropRequiresConversion = {
+ make: Hooks$RenderPropRequiresConversion
+};
+
+function Hooks$aComponentWithChildren(Props) {
+ var vehicle = Props.vehicle;
+ var children = Props.children;
+ return React.createElement("div", undefined, "Another Hook " + vehicle.name, React.createElement("div", undefined, children));
+}
+
+var make = Hooks;
+
+var $$default = Hooks;
+
+var anotherComponent = Hooks$anotherComponent;
+
+var componentWithRenamedArgs = Hooks$componentWithRenamedArgs;
+
+var makeWithRef = Hooks$makeWithRef;
+
+var polymorphicComponent = Hooks$polymorphicComponent;
+
+var functionReturningReactElement = Hooks$functionReturningReactElement;
+
+var aComponentWithChildren = Hooks$aComponentWithChildren;
+
+export {
+ make ,
+ $$default ,
+ $$default as default,
+ anotherComponent ,
+ Inner ,
+ NoProps ,
+ functionWithRenamedArgs ,
+ componentWithRenamedArgs ,
+ makeWithRef ,
+ testForwardRef ,
+ input ,
+ polymorphicComponent ,
+ functionReturningReactElement ,
+ RenderPropRequiresConversion ,
+ aComponentWithChildren ,
+
+}
+/* testForwardRef Not a pure module */
diff --git a/analysis/examples/larger-project/src/Hooks.res b/analysis/examples/larger-project/src/Hooks.res
new file mode 100644
index 000000000..f35c24287
--- /dev/null
+++ b/analysis/examples/larger-project/src/Hooks.res
@@ -0,0 +1,115 @@
+type vehicle = {name: string}
+
+@react.component
+let make = (~vehicle) => {
+ let (count, setCount) = React.useState(() => 0)
+
+
+
+ {React.string(
+ "Hooks example " ++ (vehicle.name ++ (" clicked " ++ (string_of_int(count) ++ " times"))),
+ )}
+
+
+
React.string(x["randomString"])}>
+ {React.string("child1")} {React.string("child2")}
+
+
React.string(x["randomString"])}>
+ {React.string("child1")} {React.string("child2")}
+
+
+}
+
+@genType
+let default = make
+
+@genType @react.component
+let anotherComponent = (~vehicle, ~callback: unit => unit) => {
+ callback()
+ {React.string("Another Hook " ++ vehicle.name)}
+}
+
+module Inner = {
+ @genType @react.component
+ let make = (~vehicle) => {React.string("Another Hook " ++ vehicle.name)}
+
+ @genType @react.component
+ let anotherComponent = (~vehicle) => {React.string("Another Hook " ++ vehicle.name)}
+
+ module Inner2 = {
+ @genType @react.component
+ let make = (~vehicle) => {React.string("Another Hook " ++ vehicle.name)}
+
+ @genType @react.component
+ let anotherComponent = (~vehicle) =>
+ {React.string("Another Hook " ++ vehicle.name)}
+ }
+}
+
+module NoProps = {
+ @genType @react.component
+ let make = () => React.null
+}
+
+type cb = (~_to: vehicle) => unit
+
+@genType
+let functionWithRenamedArgs = (~_to, ~_Type, ~cb: cb) => {
+ cb(~_to)
+ _to.name ++ _Type.name
+}
+
+@genType @react.component
+let componentWithRenamedArgs = (~_to, ~_Type, ~cb: cb) => {
+ cb(~_to)
+ React.string(_to.name ++ _Type.name)
+}
+
+@genType @react.component
+let makeWithRef = (~vehicle) => {
+ let _ = 34
+ ref =>
+ switch ref->Js.Nullable.toOption {
+ | Some(ref) =>
+ | None => React.null
+ }
+}
+
+@genType
+let testForwardRef = React.forwardRef(makeWithRef)
+
+type r = {x: string}
+
+@genType @react.component
+let input = React.forwardRef((~r, (), ref) => {React.string(r.x)}
)
+
+@genType
+type callback<'input, 'output> = React.callback<'input, 'output>
+
+@genType
+type testReactContext = React.Context.t
+
+@genType
+type testReactRef = React.Ref.t
+
+@genType
+type testDomRef = ReactDOM.domRef
+
+@genType @react.component
+let polymorphicComponent = (~p as (x, _)) => React.string(x.name)
+
+@genType @react.component
+let functionReturningReactElement = (~name) => React.string(name)
+
+module RenderPropRequiresConversion = {
+ @genType @react.component
+ let make = (~renderVehicle: {"vehicle": vehicle, "number": int} => React.element) => {
+ let car = {name: "Car"}
+ renderVehicle({"vehicle": car, "number": 42})
+ }
+}
+
+@genType @react.component
+let aComponentWithChildren = (~vehicle, ~children) =>
+ {React.string("Another Hook " ++ vehicle.name)}
children
diff --git a/analysis/examples/larger-project/src/IgnoreInterface.js b/analysis/examples/larger-project/src/IgnoreInterface.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/IgnoreInterface.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/IgnoreInterface.res b/analysis/examples/larger-project/src/IgnoreInterface.res
new file mode 100644
index 000000000..d381c3d03
--- /dev/null
+++ b/analysis/examples/larger-project/src/IgnoreInterface.res
@@ -0,0 +1,2 @@
+@gentype
+type t = int
diff --git a/analysis/examples/larger-project/src/IgnoreInterface.resi b/analysis/examples/larger-project/src/IgnoreInterface.resi
new file mode 100644
index 000000000..709cbb964
--- /dev/null
+++ b/analysis/examples/larger-project/src/IgnoreInterface.resi
@@ -0,0 +1,5 @@
+// Use the annotations, and definitions, from the .re file
+@@genType.ignoreInterface
+
+@genType
+type t
diff --git a/analysis/examples/larger-project/src/ImmutableArray.js b/analysis/examples/larger-project/src/ImmutableArray.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImmutableArray.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/ImmutableArray.res b/analysis/examples/larger-project/src/ImmutableArray.res
new file mode 100644
index 000000000..e69de29bb
diff --git a/analysis/examples/larger-project/src/ImmutableArray.resi b/analysis/examples/larger-project/src/ImmutableArray.resi
new file mode 100644
index 000000000..e69de29bb
diff --git a/analysis/examples/larger-project/src/ImportHookDefault.js b/analysis/examples/larger-project/src/ImportHookDefault.js
new file mode 100644
index 000000000..119015eb5
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportHookDefault.js
@@ -0,0 +1,15 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import ImportHookDefaultGen from "./ImportHookDefault.gen";
+import * as ImportHookDefaultGen$1 from "./ImportHookDefault.gen";
+
+var make = ImportHookDefaultGen$1.make;
+
+var make2 = ImportHookDefaultGen;
+
+export {
+ make ,
+ make2 ,
+
+}
+/* make Not a pure module */
diff --git a/analysis/examples/larger-project/src/ImportHookDefault.res b/analysis/examples/larger-project/src/ImportHookDefault.res
new file mode 100644
index 000000000..61086d6ea
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportHookDefault.res
@@ -0,0 +1,18 @@
+type person = {
+ name: string,
+ age: int,
+}
+
+@genType.import(("./hookExample", "default")) @react.component
+external make: (
+ ~person: person,
+ ~children: React.element,
+ ~renderMe: ImportHooks.renderMe,
+) => React.element = "make"
+
+@genType.import("./hookExample") @react.component
+external make2: (
+ ~person: person,
+ ~children: React.element,
+ ~renderMe: ImportHooks.renderMe,
+) => React.element = "default"
diff --git a/analysis/examples/larger-project/src/ImportHooks.js b/analysis/examples/larger-project/src/ImportHooks.js
new file mode 100644
index 000000000..2296ade78
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportHooks.js
@@ -0,0 +1,16 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as ImportHooksGen from "./ImportHooks.gen";
+
+var make = ImportHooksGen.makeRenamed;
+
+function foo(prim) {
+ return ImportHooksGen.foo(prim);
+}
+
+export {
+ make ,
+ foo ,
+
+}
+/* make Not a pure module */
diff --git a/analysis/examples/larger-project/src/ImportHooks.res b/analysis/examples/larger-project/src/ImportHooks.res
new file mode 100644
index 000000000..85bfe4d18
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportHooks.res
@@ -0,0 +1,21 @@
+@genType
+type person = {
+ name: string,
+ age: int,
+}
+
+@genType
+type renderMe<'a> = React.component<{
+ "randomString": string,
+ "poly": 'a,
+}>
+
+@genType.import("./hookExample") @react.component
+external make: (
+ ~person: person,
+ ~children: React.element,
+ ~renderMe: renderMe<'a>,
+) => React.element = "makeRenamed"
+
+@genType.import("./hookExample")
+external foo: (~person: person) => string = "foo"
diff --git a/analysis/examples/larger-project/src/ImportIndex.js b/analysis/examples/larger-project/src/ImportIndex.js
new file mode 100644
index 000000000..d817c1940
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportIndex.js
@@ -0,0 +1,11 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import ImportIndexGen from "./ImportIndex.gen";
+
+var make = ImportIndexGen;
+
+export {
+ make ,
+
+}
+/* make Not a pure module */
diff --git a/analysis/examples/larger-project/src/ImportIndex.res b/analysis/examples/larger-project/src/ImportIndex.res
new file mode 100644
index 000000000..61f8998a5
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportIndex.res
@@ -0,0 +1,3 @@
+// TODO: rename metodd back once remmt bug is fixed
+@genType.import("./") @react.component
+external make: (~method: @string [#push | #replace]=?) => React.element = "default"
diff --git a/analysis/examples/larger-project/src/ImportJsValue.js b/analysis/examples/larger-project/src/ImportJsValue.js
new file mode 100644
index 000000000..b5447377e
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportJsValue.js
@@ -0,0 +1,81 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import ImportJsValueGen from "./ImportJsValue.gen";
+import * as ImportJsValueGen$1 from "./ImportJsValue.gen";
+
+function round(prim) {
+ return ImportJsValueGen$1.round(prim);
+}
+
+function area(prim) {
+ return ImportJsValueGen$1.area(prim);
+}
+
+function returnMixedArray(prim) {
+ return ImportJsValueGen$1.returnMixedArray();
+}
+
+var roundedNumber = ImportJsValueGen$1.round(1.8);
+
+var areaValue = ImportJsValueGen$1.area({
+ x: 3,
+ y: undefined
+ });
+
+function getAbs(x) {
+ return x.getAbs();
+}
+
+var AbsoluteValue = {
+ getAbs: getAbs
+};
+
+function useGetProp(x) {
+ return x.getProp() + 1 | 0;
+}
+
+function useGetAbs(x) {
+ return x.getAbs() + 1 | 0;
+}
+
+function useColor(prim) {
+ return ImportJsValueGen$1.useColor(prim);
+}
+
+function higherOrder(prim) {
+ return ImportJsValueGen$1.higherOrder(prim);
+}
+
+var returnedFromHigherOrder = ImportJsValueGen$1.higherOrder(function (prim0, prim1) {
+ return prim0 + prim1 | 0;
+ });
+
+function convertVariant(prim) {
+ return ImportJsValueGen$1.convertVariant(prim);
+}
+
+function polymorphic(prim) {
+ return ImportJsValueGen$1.polymorphic(prim);
+}
+
+var $$default = ImportJsValueGen;
+
+export {
+ round ,
+ area ,
+ returnMixedArray ,
+ roundedNumber ,
+ areaValue ,
+ AbsoluteValue ,
+ useGetProp ,
+ useGetAbs ,
+ useColor ,
+ higherOrder ,
+ returnedFromHigherOrder ,
+ convertVariant ,
+ polymorphic ,
+ $$default ,
+ $$default as default,
+
+}
+/* roundedNumber Not a pure module */
diff --git a/analysis/examples/larger-project/src/ImportJsValue.res b/analysis/examples/larger-project/src/ImportJsValue.res
new file mode 100644
index 000000000..7728ca527
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportJsValue.res
@@ -0,0 +1,84 @@
+@ocaml.doc("
+ * Wrap JS values to be used from Reason
+ ")
+@genType.import("./MyMath")
+external /* This is the module to import from. */
+/* Name and type of the JS value to bind to. */
+round: float => float = "round"
+
+@genType
+type point = {
+ x: int,
+ y: option,
+}
+
+@genType.import("./MyMath")
+external /* This is the module to import from. */
+/* Name and type of the JS value to bind to. */
+area: point => int = "area"
+
+@genType.import("./MyMath")
+type numberOrString
+
+@genType.import("./MyMath")
+external returnMixedArray: unit => array = "returnMixedArray"
+
+@genType
+let roundedNumber = round(1.8)
+
+@genType
+let areaValue = area({x: 3, y: None})
+
+module AbsoluteValue = {
+ @genType.import(("./MyMath", "AbsoluteValue"))
+ type t = {"getAbs": (. unit) => int}
+
+ /* This is untyped */
+ @send external getProp: t => int = "getProp"
+
+ /* This is also untyped, as we "trust" the type declaration in absoluteVaue */
+ let getAbs = (x: t) => {
+ let getAbs = x["getAbs"]
+ getAbs(.)
+ }
+}
+
+@genType
+let useGetProp = (x: AbsoluteValue.t) => x->AbsoluteValue.getProp + 1
+
+@genType
+let useGetAbs = (x: AbsoluteValue.t) => x->AbsoluteValue.getAbs + 1
+
+@genType.import("./MyMath")
+type stringFunction
+
+@genType
+type color = [#tomato | #gray]
+
+@genType.import("./MyMath") external useColor: color => int = "useColor"
+
+@genType.import("./MyMath")
+external higherOrder: ((int, int) => int) => int = "higherOrder"
+
+@genType
+let returnedFromHigherOrder = higherOrder(\"+")
+
+type variant =
+ | I(int)
+ | S(string)
+
+@genType.import("./MyMath")
+external convertVariant: variant => variant = "convertVariant"
+
+@genType.import("./MyMath") external polymorphic: 'a => 'a = "polymorphic"
+
+@genType.import("./MyMath") external default: int = "default"
+
+@genType.import(("./MyMath", "num"))
+type num
+
+@genType.import(("./MyMath", "num"))
+type myNum
+
+@genType.import("./MyMath")
+type polyType<'a>
diff --git a/analysis/examples/larger-project/src/ImportMyBanner.js b/analysis/examples/larger-project/src/ImportMyBanner.js
new file mode 100644
index 000000000..ffc3d6ed5
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportMyBanner.js
@@ -0,0 +1,14 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Caml_option from "rescript/lib/es6/caml_option.js";
+import * as ImportMyBannerGen from "./ImportMyBanner.gen";
+
+function make(prim0, prim1, prim2) {
+ return ImportMyBannerGen.make(prim0, prim1 !== undefined ? Caml_option.valFromOption(prim1) : undefined, prim2);
+}
+
+export {
+ make ,
+
+}
+/* ./ImportMyBanner.gen Not a pure module */
diff --git a/analysis/examples/larger-project/src/ImportMyBanner.res b/analysis/examples/larger-project/src/ImportMyBanner.res
new file mode 100644
index 000000000..9b26fa236
--- /dev/null
+++ b/analysis/examples/larger-project/src/ImportMyBanner.res
@@ -0,0 +1,12 @@
+@ocaml.doc("
+ * Wrap component MyBanner to be used from Reason.
+ ")
+@genType
+type message = {text: string}
+
+@genType.import("./MyBanner")
+external /* Module with the JS component to be wrapped. */
+/* The make function will be automatically generated from the types below. */
+make: (~show: bool, ~message: option=?, 'a) => React.element = "make"
+
+let make = make
diff --git a/analysis/examples/larger-project/src/JSResource.js b/analysis/examples/larger-project/src/JSResource.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/JSResource.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/JSResource.res b/analysis/examples/larger-project/src/JSResource.res
new file mode 100644
index 000000000..432c4a466
--- /dev/null
+++ b/analysis/examples/larger-project/src/JSResource.res
@@ -0,0 +1,3 @@
+type t<'a>
+
+@module external jSResource: string => t<'a> = "JSResource"
diff --git a/analysis/examples/larger-project/src/LetPrivate.js b/analysis/examples/larger-project/src/LetPrivate.js
new file mode 100644
index 000000000..25dbf8d5b
--- /dev/null
+++ b/analysis/examples/larger-project/src/LetPrivate.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var y = 34;
+
+export {
+ y ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/LetPrivate.res b/analysis/examples/larger-project/src/LetPrivate.res
new file mode 100644
index 000000000..758270659
--- /dev/null
+++ b/analysis/examples/larger-project/src/LetPrivate.res
@@ -0,0 +1,7 @@
+%%private(
+ @genType
+ let x = 34
+)
+
+@genType
+let y = x
diff --git a/analysis/examples/larger-project/src/ModuleAliases.js b/analysis/examples/larger-project/src/ModuleAliases.js
new file mode 100644
index 000000000..bbe92275a
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleAliases.js
@@ -0,0 +1,48 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var Inner = {};
+
+var Outer = {
+ Inner: Inner
+};
+
+var InnerNested = {};
+
+var Inner2 = {
+ InnerNested: InnerNested,
+ OuterInnerAlias2: undefined
+};
+
+var Outer2 = {
+ OuterInnerAlias: undefined,
+ Inner2: Inner2
+};
+
+function testNested(x) {
+ return x;
+}
+
+function testInner(x) {
+ return x;
+}
+
+function testInner2(x) {
+ return x;
+}
+
+var Outer2Alias;
+
+var InnerNestedAlias;
+
+export {
+ Outer ,
+ Outer2 ,
+ Outer2Alias ,
+ InnerNestedAlias ,
+ testNested ,
+ testInner ,
+ testInner2 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/ModuleAliases.res b/analysis/examples/larger-project/src/ModuleAliases.res
new file mode 100644
index 000000000..93c612acb
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleAliases.res
@@ -0,0 +1,28 @@
+module Outer = {
+ module Inner = {
+ type innerT = {inner: string}
+ }
+}
+
+module Outer2 = {
+ module OuterInnerAlias = Outer.Inner
+ module Inner2 = {
+ module InnerNested = {
+ type t = {nested: int}
+ }
+ module OuterInnerAlias2 = OuterInnerAlias
+ }
+}
+
+module Outer2Alias = Outer2
+
+module InnerNestedAlias = Outer2.Inner2.InnerNested
+
+@genType
+let testNested = (x: InnerNestedAlias.t) => x
+
+@genType
+let testInner = (x: Outer2Alias.OuterInnerAlias.innerT) => x
+
+@genType
+let testInner2 = (x: Outer2Alias.Inner2.OuterInnerAlias2.innerT) => x
diff --git a/analysis/examples/larger-project/src/ModuleAliases2.js b/analysis/examples/larger-project/src/ModuleAliases2.js
new file mode 100644
index 000000000..59a7eb648
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleAliases2.js
@@ -0,0 +1,23 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var Inner = {};
+
+var Outer = {
+ Inner: Inner
+};
+
+var OuterAlias;
+
+var InnerAlias;
+
+var q = 42;
+
+export {
+ Outer ,
+ OuterAlias ,
+ InnerAlias ,
+ q ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/ModuleAliases2.res b/analysis/examples/larger-project/src/ModuleAliases2.res
new file mode 100644
index 000000000..b0ce0265c
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleAliases2.res
@@ -0,0 +1,21 @@
+@genType
+type record = {
+ x: int,
+ y: string,
+}
+
+module Outer = {
+ @genType
+ type outer = {outer: string}
+
+ module Inner = {
+ @genType
+ type inner = {inner: string}
+ }
+}
+
+module OuterAlias = Outer
+
+module InnerAlias = OuterAlias.Inner
+
+let q = 42
diff --git a/analysis/examples/larger-project/src/ModuleExceptionBug.js b/analysis/examples/larger-project/src/ModuleExceptionBug.js
new file mode 100644
index 000000000..6679d3d6f
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleExceptionBug.js
@@ -0,0 +1,25 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
+
+function customDouble(foo) {
+ return (foo << 1);
+}
+
+var Dep = {
+ customDouble: customDouble
+};
+
+var MyOtherException = /* @__PURE__ */Caml_exceptions.create("ModuleExceptionBug.MyOtherException");
+
+console.log(34);
+
+var ddjdj = 34;
+
+export {
+ Dep ,
+ MyOtherException ,
+ ddjdj ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/ModuleExceptionBug.res b/analysis/examples/larger-project/src/ModuleExceptionBug.res
new file mode 100644
index 000000000..f9b36ce23
--- /dev/null
+++ b/analysis/examples/larger-project/src/ModuleExceptionBug.res
@@ -0,0 +1,8 @@
+module Dep = {
+ let customDouble = foo => foo * 2
+}
+
+exception MyOtherException
+
+let ddjdj = 34
+Js.log(ddjdj)
diff --git a/analysis/examples/larger-project/src/NestedModules.js b/analysis/examples/larger-project/src/NestedModules.js
new file mode 100644
index 000000000..fd32bddea
--- /dev/null
+++ b/analysis/examples/larger-project/src/NestedModules.js
@@ -0,0 +1,43 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function nested3Function(x) {
+ return x;
+}
+
+var Nested3 = {
+ x: 0,
+ y: 1,
+ z: 2,
+ w: 3,
+ nested3Value: "nested3Value",
+ nested3Function: nested3Function
+};
+
+function nested2Function(x) {
+ return x;
+}
+
+var Nested2 = {
+ x: 0,
+ nested2Value: 1,
+ y: 2,
+ Nested3: Nested3,
+ nested2Function: nested2Function
+};
+
+var Universe = {
+ theAnswer: 42,
+ notExported: 33,
+ Nested2: Nested2,
+ someString: "some exported string"
+};
+
+var notNested = 1;
+
+export {
+ notNested ,
+ Universe ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/NestedModules.res b/analysis/examples/larger-project/src/NestedModules.res
new file mode 100644
index 000000000..f2317d194
--- /dev/null
+++ b/analysis/examples/larger-project/src/NestedModules.res
@@ -0,0 +1,51 @@
+@genType
+let notNested = 1
+
+module Universe = {
+ @genType
+ let theAnswer = 42
+
+ let notExported = 33
+
+ @genType
+ type nestedType = array
+
+ module Nested2 = {
+ let x = 0
+
+ @genType
+ let nested2Value = 1
+
+ let y = 2
+
+ @genType
+ type nested2Type = array>
+
+ module Nested3 = {
+ let x = 0
+ let y = 1
+ let z = 2
+ let w = 3
+
+ @genType
+ type nested3Type = array>>
+
+ @genType
+ let nested3Value = "nested3Value"
+
+ @genType
+ let nested3Function = (x: nested2Type) => x
+ }
+
+ @genType
+ let nested2Function = (x: Nested3.nested3Type) => x
+ }
+
+ @genType
+ type variant =
+ | A
+ | B(string)
+
+ @genType
+ let someString = "some exported string"
+}
diff --git a/analysis/examples/larger-project/src/NestedModulesInSignature.js b/analysis/examples/larger-project/src/NestedModulesInSignature.js
new file mode 100644
index 000000000..101951300
--- /dev/null
+++ b/analysis/examples/larger-project/src/NestedModulesInSignature.js
@@ -0,0 +1,12 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var Universe = {
+ theAnswer: 42
+};
+
+export {
+ Universe ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/NestedModulesInSignature.res b/analysis/examples/larger-project/src/NestedModulesInSignature.res
new file mode 100644
index 000000000..85f454db9
--- /dev/null
+++ b/analysis/examples/larger-project/src/NestedModulesInSignature.res
@@ -0,0 +1,3 @@
+module Universe = {
+ let theAnswer = 42
+}
diff --git a/analysis/examples/larger-project/src/NestedModulesInSignature.resi b/analysis/examples/larger-project/src/NestedModulesInSignature.resi
new file mode 100644
index 000000000..482b8ca52
--- /dev/null
+++ b/analysis/examples/larger-project/src/NestedModulesInSignature.resi
@@ -0,0 +1,4 @@
+module Universe: {
+ @genType
+ let theAnswer: int
+}
diff --git a/analysis/examples/larger-project/src/Newsyntax.js b/analysis/examples/larger-project/src/Newsyntax.js
new file mode 100644
index 000000000..8a024f19d
--- /dev/null
+++ b/analysis/examples/larger-project/src/Newsyntax.js
@@ -0,0 +1,13 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var x = 34;
+
+var y = 11;
+
+export {
+ x ,
+ y ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Newsyntax.res b/analysis/examples/larger-project/src/Newsyntax.res
new file mode 100644
index 000000000..45f118b40
--- /dev/null
+++ b/analysis/examples/larger-project/src/Newsyntax.res
@@ -0,0 +1,12 @@
+let x = 34
+
+let y = 11
+
+type record = {
+ xxx: int,
+ yyy: int,
+}
+
+type variant = A | B(int) | C
+
+type record2 = {xx: int, yy: int}
diff --git a/analysis/examples/larger-project/src/Newton.js b/analysis/examples/larger-project/src/Newton.js
new file mode 100644
index 000000000..5f603b0e8
--- /dev/null
+++ b/analysis/examples/larger-project/src/Newton.js
@@ -0,0 +1,65 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Curry from "rescript/lib/es6/curry.js";
+
+function $neg(prim0, prim1) {
+ return prim0 - prim1;
+}
+
+function $plus(prim0, prim1) {
+ return prim0 + prim1;
+}
+
+function $star(prim0, prim1) {
+ return prim0 * prim1;
+}
+
+function $slash(prim0, prim1) {
+ return prim0 / prim1;
+}
+
+function newton(f, fPrimed, initial, threshold) {
+ var current = {
+ contents: initial
+ };
+ var iterateMore = function (previous, next) {
+ var delta = next >= previous ? next - previous : previous - next;
+ current.contents = next;
+ return delta >= threshold;
+ };
+ var _param;
+ while(true) {
+ var previous = current.contents;
+ var next = previous - Curry._1(f, previous) / Curry._1(fPrimed, previous);
+ if (!iterateMore(previous, next)) {
+ return current.contents;
+ }
+ _param = undefined;
+ continue ;
+ };
+}
+
+function f(x) {
+ return x * x * x - 2.0 * x * x - 11.0 * x + 12.0;
+}
+
+function fPrimed(x) {
+ return 3.0 * x * x - 4.0 * x - 11.0;
+}
+
+var result = newton(f, fPrimed, 5.0, 0.0003);
+
+console.log(result, f(result));
+
+export {
+ $neg ,
+ $plus ,
+ $star ,
+ $slash ,
+ newton ,
+ f ,
+ fPrimed ,
+ result ,
+
+}
+/* result Not a pure module */
diff --git a/analysis/examples/larger-project/src/Newton.res b/analysis/examples/larger-project/src/Newton.res
new file mode 100644
index 000000000..4601b2bc4
--- /dev/null
+++ b/analysis/examples/larger-project/src/Newton.res
@@ -0,0 +1,32 @@
+let \"-" = \"-."
+let \"+" = \"+."
+let \"*" = \"*."
+let \"/" = \"/."
+
+let newton = (~f, ~fPrimed, ~initial, ~threshold) => {
+ let current = ref(initial)
+ let iterateMore = (previous, next) => {
+ let delta = next >= previous ? next - previous : previous - next
+ current := next
+ !(delta < threshold)
+ }
+
+ @progress(iterateMore)
+ let rec loop = () => {
+ let previous = current.contents
+ let next = previous - f(previous) / fPrimed(previous)
+ if iterateMore(previous, next) {
+ loop()
+ } else {
+ current.contents
+ }
+ }
+ loop()
+}
+let f = x => x * x * x - 2.0 * x * x - 11.0 * x + 12.0
+
+let fPrimed = x => 3.0 * x * x - 4.0 * x - 11.0
+
+let result = newton(~f, ~fPrimed, ~initial=5.0, ~threshold=0.0003)
+
+Js.log2(result, f(result))
diff --git a/analysis/examples/larger-project/src/Opaque.js b/analysis/examples/larger-project/src/Opaque.js
new file mode 100644
index 000000000..17f41cac2
--- /dev/null
+++ b/analysis/examples/larger-project/src/Opaque.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function noConversion(x) {
+ return x;
+}
+
+function testConvertNestedRecordFromOtherFile(x) {
+ return x;
+}
+
+export {
+ noConversion ,
+ testConvertNestedRecordFromOtherFile ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Opaque.res b/analysis/examples/larger-project/src/Opaque.res
new file mode 100644
index 000000000..e6772142a
--- /dev/null
+++ b/analysis/examples/larger-project/src/Opaque.res
@@ -0,0 +1,11 @@
+@genType.opaque
+type opaqueFromRecords = A(Records.coord)
+
+@genType
+let noConversion = (x: opaqueFromRecords) => x
+
+@genType
+type pair = (opaqueFromRecords, opaqueFromRecords)
+
+@genType
+let testConvertNestedRecordFromOtherFile = (x: Records.business) => x
diff --git a/analysis/examples/larger-project/src/OptArg.js b/analysis/examples/larger-project/src/OptArg.js
new file mode 100644
index 000000000..1900ecd3c
--- /dev/null
+++ b/analysis/examples/larger-project/src/OptArg.js
@@ -0,0 +1,60 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function foo(xOpt, yOpt, zOpt, w) {
+ var x = xOpt !== undefined ? xOpt : 1;
+ var y = yOpt !== undefined ? yOpt : 2;
+ var z = zOpt !== undefined ? zOpt : 3;
+ return ((x + y | 0) + z | 0) + w | 0;
+}
+
+function bar(x, y, z, w) {
+ return y + w | 0;
+}
+
+console.log(foo(3, undefined, undefined, 4));
+
+console.log(7);
+
+function threeArgs(aOpt, bOpt, cOpt, d) {
+ var a = aOpt !== undefined ? aOpt : 1;
+ var b = bOpt !== undefined ? bOpt : 2;
+ var c = cOpt !== undefined ? cOpt : 3;
+ return ((a + b | 0) + c | 0) + d | 0;
+}
+
+console.log(threeArgs(4, undefined, 7, 1));
+
+console.log(threeArgs(4, undefined, undefined, 1));
+
+function twoArgs(aOpt, bOpt, c) {
+ var a = aOpt !== undefined ? aOpt : 1;
+ var b = bOpt !== undefined ? bOpt : 2;
+ return (a + b | 0) + c | 0;
+}
+
+console.log(twoArgs(undefined, undefined, 1));
+
+var a = 3;
+
+console.log(a + 44 | 0);
+
+function wrapfourArgs(a, b, c, n) {
+ var dOpt;
+ var a$1 = a !== undefined ? a : 1;
+ var b$1 = b !== undefined ? b : 2;
+ var c$1 = c !== undefined ? c : 3;
+ var d = dOpt !== undefined ? dOpt : 4;
+ return (((a$1 + b$1 | 0) + c$1 | 0) + d | 0) + n | 0;
+}
+
+console.log(wrapfourArgs(3, undefined, 44, 44));
+
+console.log(wrapfourArgs(undefined, 4, 44, 44));
+
+export {
+ foo ,
+ bar ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/OptArg.res b/analysis/examples/larger-project/src/OptArg.res
new file mode 100644
index 000000000..a38e8bfc4
--- /dev/null
+++ b/analysis/examples/larger-project/src/OptArg.res
@@ -0,0 +1,29 @@
+let foo = (~x=1, ~y=2, ~z=3, w) => x + y + z + w
+
+let bar = (~x=?, ~y, ~z=?, w) => y + w
+
+Js.log(foo(~x=3, 4))
+
+Js.log(bar(~y=3, 4))
+
+let threeArgs = (~a=1, ~b=2, ~c=3, d) => a + b + c + d
+
+Js.log(threeArgs(~a=4, ~c=7, 1))
+Js.log(threeArgs(~a=4, 1))
+
+let twoArgs = (~a=1, ~b=2, c) => a + b + c
+
+Js.log(1 |> twoArgs)
+
+let oneArg = (~a=1, ~z, b) => a + b
+
+let wrapOneArg = (~a=?, n) => oneArg(~a?, ~z=33, n)
+
+Js.log(wrapOneArg(~a=3, 44))
+
+let fourArgs = (~a=1, ~b=2, ~c=3, ~d=4, n) => a + b + c + d + n
+
+let wrapfourArgs = (~a=?, ~b=?, ~c=?, n) => fourArgs(~a?, ~b?, ~c?, n)
+
+Js.log(wrapfourArgs(~a=3, ~c=44, 44))
+Js.log(wrapfourArgs(~b=4, ~c=44, 44))
diff --git a/analysis/examples/larger-project/src/OptArg.resi b/analysis/examples/larger-project/src/OptArg.resi
new file mode 100644
index 000000000..8145a5116
--- /dev/null
+++ b/analysis/examples/larger-project/src/OptArg.resi
@@ -0,0 +1,2 @@
+let foo: (~x: int=?, ~y: int=?, ~z: int=?, int) => int
+let bar: (~x: 'a=?, ~y: int, ~z: 'b=?, int) => int
diff --git a/analysis/examples/larger-project/src/Records.js b/analysis/examples/larger-project/src/Records.js
new file mode 100644
index 000000000..016884c0e
--- /dev/null
+++ b/analysis/examples/larger-project/src/Records.js
@@ -0,0 +1,170 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Belt_List from "rescript/lib/es6/belt_List.js";
+import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
+import * as Pervasives from "rescript/lib/es6/pervasives.js";
+import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
+import * as Caml_option from "rescript/lib/es6/caml_option.js";
+
+function computeArea(param) {
+ return Math.imul(Math.imul(param.x, param.y), Belt_Option.mapWithDefault(param.z, 1, (function (n) {
+ return n;
+ })));
+}
+
+function coord2d(x, y) {
+ return {
+ x: x,
+ y: y,
+ z: undefined
+ };
+}
+
+var getOpt = Belt_Option.mapWithDefault;
+
+function findAddress(business) {
+ return Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) {
+ return {
+ hd: a,
+ tl: /* [] */0
+ };
+ }));
+}
+
+function findAllAddresses(businesses) {
+ return Belt_List.toArray(Belt_List.flatten(Belt_List.fromArray(Belt_Array.map(businesses, (function (business) {
+ return Pervasives.$at(Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) {
+ return {
+ hd: a,
+ tl: /* [] */0
+ };
+ })), Belt_Option.mapWithDefault(business.owner, /* [] */0, (function (p) {
+ return Belt_Option.mapWithDefault(p.address, /* [] */0, (function (a) {
+ return {
+ hd: a,
+ tl: /* [] */0
+ };
+ }));
+ })));
+ })))));
+}
+
+function getPayload(param) {
+ return param.payload;
+}
+
+function getPayloadRecord(param) {
+ return param.payload;
+}
+
+var recordValue = {
+ v: 1,
+ w: 1
+};
+
+var payloadValue = {
+ num: 1,
+ payload: recordValue
+};
+
+function getPayloadRecordPlusOne(param) {
+ var payload = param.payload;
+ return {
+ v: payload.v + 1 | 0,
+ w: payload.w
+ };
+}
+
+function findAddress2(business) {
+ return Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(business.address2), /* [] */0, (function (a) {
+ return {
+ hd: a,
+ tl: /* [] */0
+ };
+ }));
+}
+
+var someBusiness2_owner = null;
+
+var someBusiness2_address2 = null;
+
+var someBusiness2 = {
+ name: "SomeBusiness",
+ owner: someBusiness2_owner,
+ address2: someBusiness2_address2
+};
+
+function computeArea3(o) {
+ return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(o.z), 1, (function (n) {
+ return n;
+ })));
+}
+
+function computeArea4(o) {
+ return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(o.z, 1, (function (n) {
+ return n;
+ })));
+}
+
+function testMyRec(x) {
+ return x.type_;
+}
+
+function testMyRec2(x) {
+ return x;
+}
+
+function testMyObj(x) {
+ return x.type_;
+}
+
+function testMyObj2(x) {
+ return x;
+}
+
+function testMyRecBsAs(x) {
+ return x.type;
+}
+
+function testMyRecBsAs2(x) {
+ return x;
+}
+
+var origin = {
+ x: 0,
+ y: 0,
+ z: 0
+};
+
+var someBusiness = {
+ name: "SomeBusiness",
+ owner: undefined,
+ address: undefined
+};
+
+export {
+ origin ,
+ computeArea ,
+ coord2d ,
+ getOpt ,
+ findAddress ,
+ someBusiness ,
+ findAllAddresses ,
+ getPayload ,
+ getPayloadRecord ,
+ recordValue ,
+ payloadValue ,
+ getPayloadRecordPlusOne ,
+ findAddress2 ,
+ someBusiness2 ,
+ computeArea3 ,
+ computeArea4 ,
+ testMyRec ,
+ testMyRec2 ,
+ testMyObj ,
+ testMyObj2 ,
+ testMyRecBsAs ,
+ testMyRecBsAs2 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Records.res b/analysis/examples/larger-project/src/Records.res
new file mode 100644
index 000000000..e82745e48
--- /dev/null
+++ b/analysis/examples/larger-project/src/Records.res
@@ -0,0 +1,148 @@
+open Belt
+
+@genType
+type coord = {
+ x: int,
+ y: int,
+ z: option,
+}
+
+@genType
+let origin = {x: 0, y: 0, z: Some(0)}
+
+@genType
+let computeArea = ({x, y, z}) => {
+ open Option
+ x * y * z->mapWithDefault(1, n => n)
+}
+
+@genType
+let coord2d = (x, y) => {x: x, y: y, z: None}
+
+@genType
+type person = {
+ name: string,
+ age: int,
+ address: option,
+}
+
+@genType
+type business = {
+ name: string,
+ owner: option,
+ address: option,
+}
+
+let getOpt = (opt, default, foo) => opt->Option.mapWithDefault(default, foo)
+
+@genType
+let findAddress = (business: business): list =>
+ business.address->getOpt(list{}, a => list{a})
+
+@genType
+let someBusiness = {name: "SomeBusiness", owner: None, address: None}
+
+@genType
+let findAllAddresses = (businesses: array): array =>
+ businesses
+ ->Array.map(business =>
+ \"@"(
+ business.address->getOpt(list{}, a => list{a}),
+ business.owner->getOpt(list{}, p => p.address->getOpt(list{}, a => list{a})),
+ )
+ )
+ ->List.fromArray
+ ->List.flatten
+ ->List.toArray
+
+@genType
+type payload<'a> = {
+ num: int,
+ payload: 'a,
+}
+
+@genType
+let getPayload = ({payload}) => payload
+
+@genType
+type record = {
+ v: int,
+ w: int,
+}
+
+@genType
+let getPayloadRecord = ({payload}): record => payload
+
+@genType
+let recordValue = {v: 1, w: 1}
+
+@genType
+let payloadValue = {num: 1, payload: recordValue}
+
+@genType
+let getPayloadRecordPlusOne = ({payload}): record => {
+ ...payload,
+ v: payload.v + 1,
+}
+
+@genType
+type business2 = {
+ name: string,
+ owner: Js.Nullable.t,
+ address2: Js.Nullable.t,
+}
+
+@genType
+let findAddress2 = (business: business2): list =>
+ business.address2->Js.Nullable.toOption->getOpt(list{}, a => list{a})
+
+@genType
+let someBusiness2 = {
+ name: "SomeBusiness",
+ owner: Js.Nullable.null,
+ address2: Js.Nullable.null,
+}
+
+@genType
+let computeArea3 = (o: {"x": int, "y": int, "z": Js.Nullable.t}) =>
+ o["x"] * o["y"] * o["z"]->Js.Nullable.toOption->Option.mapWithDefault(1, n => n)
+
+@genType
+let computeArea4 = (o: {"x": int, "y": int, "z": option}) =>
+ o["x"] * o["y"] * o["z"]->Option.mapWithDefault(1, n => n)
+
+@genType
+type mix = {"a": int, "b": int, "c": option<{"name": string, "surname": string}>}
+
+@genType
+type myRec = {
+ @genType.as("type")
+ type_: string,
+}
+
+@genType
+type myObj = {"type_": string}
+
+@genType
+let testMyRec = (x: myRec) => x.type_
+
+@genType
+let testMyRec2 = (x: myRec) => x
+
+@genType
+let testMyObj = (x: myObj) => x["type_"]
+
+@genType
+let testMyObj2 = (x: myObj) => x
+
+@genType
+type myRecBsAs = {
+ @as("type")
+ type_: string,
+}
+
+@genType
+let testMyRecBsAs = (x: myRecBsAs) => x.type_
+
+@genType
+let testMyRecBsAs2 = (x: myRecBsAs) => x
diff --git a/analysis/examples/larger-project/src/References.js b/analysis/examples/larger-project/src/References.js
new file mode 100644
index 000000000..41dbd5947
--- /dev/null
+++ b/analysis/examples/larger-project/src/References.js
@@ -0,0 +1,60 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function create(x) {
+ return {
+ contents: x
+ };
+}
+
+function access(r) {
+ return r.contents + 1 | 0;
+}
+
+function update(r) {
+ r.contents = r.contents + 1 | 0;
+
+}
+
+function get(r) {
+ return r.contents;
+}
+
+function make(prim) {
+ return {
+ contents: prim
+ };
+}
+
+function set(r, v) {
+ r.contents = v;
+
+}
+
+var R = {
+ get: get,
+ make: make,
+ set: set
+};
+
+function destroysRefIdentity(x) {
+ return x;
+}
+
+function preserveRefIdentity(x) {
+ return x;
+}
+
+export {
+ create ,
+ access ,
+ update ,
+ R ,
+ get ,
+ make ,
+ set ,
+ destroysRefIdentity ,
+ preserveRefIdentity ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/References.res b/analysis/examples/larger-project/src/References.res
new file mode 100644
index 000000000..fa4ae2bfc
--- /dev/null
+++ b/analysis/examples/larger-project/src/References.res
@@ -0,0 +1,47 @@
+// Test pervasive references
+
+@genType
+let create = (x: int) => ref(x)
+
+@genType
+let access = r => r.contents + 1
+
+@genType
+let update = r => r.contents = r.contents + 1
+
+// Abstract version of references: works when conversion is required.
+
+module R: {
+ @genType
+ type t<'a>
+ let get: t<'a> => 'a
+ let make: 'a => t<'a>
+ let set: (t<'a>, 'a) => unit
+} = {
+ type t<'a> = ref<'a>
+ let get = r => r.contents
+ let make = ref
+ let set = (r, v) => r.contents = v
+}
+
+@genType
+type t<'a> = R.t<'a>
+
+@genType
+let get = R.get
+
+@gentype
+let make = R.make
+
+@genType
+let set = R.set
+
+type requiresConversion = {x: int}
+
+// Careful: conversion makes a copy and destroys the reference identity.
+@genType
+let destroysRefIdentity = (x: ref) => x
+
+// Using abstract references preserves the identity.
+@genType
+let preserveRefIdentity = (x: R.t) => x
diff --git a/analysis/examples/larger-project/src/RepeatedLabel.js b/analysis/examples/larger-project/src/RepeatedLabel.js
new file mode 100644
index 000000000..fba30a9dd
--- /dev/null
+++ b/analysis/examples/larger-project/src/RepeatedLabel.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function userData(param) {
+ return {
+ a: param.a,
+ b: param.b
+ };
+}
+
+console.log(userData);
+
+export {
+ userData ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/RepeatedLabel.res b/analysis/examples/larger-project/src/RepeatedLabel.res
new file mode 100644
index 000000000..64fda7279
--- /dev/null
+++ b/analysis/examples/larger-project/src/RepeatedLabel.res
@@ -0,0 +1,14 @@
+type userData = {
+ a: bool,
+ b: int,
+}
+
+type tabState = {
+ a: bool,
+ b: int,
+ f: string,
+}
+
+let userData = ({a, b}): userData => {a: a, b: b}
+
+Js.log(userData)
diff --git a/analysis/examples/larger-project/src/RequireCond.js b/analysis/examples/larger-project/src/RequireCond.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/RequireCond.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/RequireCond.res b/analysis/examples/larger-project/src/RequireCond.res
new file mode 100644
index 000000000..b7fdd67a3
--- /dev/null
+++ b/analysis/examples/larger-project/src/RequireCond.res
@@ -0,0 +1,19 @@
+@module
+@deprecated(
+ "Please use this syntax to guarantee safe usage: [%requireCond(`gk, \"gk_name\", ConditionalModule)]"
+)
+external make: (
+ @string [@as("qe.bool") #qeBool | @as("gk") #gk],
+ string,
+ string,
+) => Js.Nullable.t<'a> = "requireCond"
+
+@module
+@deprecated(
+ "Please use this syntax to guarantee safe usage: [%requireCond(`gk, \"gk_name\", {\"true\": ModuleA, \"false\": ModuleB})]"
+)
+external either: (
+ @string [@as("qe.bool") #qeBool | @as("gk") #gk],
+ string,
+ {"true": string, "false": string},
+) => 'b = "requireCond"
diff --git a/analysis/examples/larger-project/src/Shadow.js b/analysis/examples/larger-project/src/Shadow.js
new file mode 100644
index 000000000..3d1c79858
--- /dev/null
+++ b/analysis/examples/larger-project/src/Shadow.js
@@ -0,0 +1,21 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function test(param) {
+ return "a";
+}
+
+function test$1(param) {
+ return "a";
+}
+
+var M = {
+ test: test$1
+};
+
+export {
+ test ,
+ M ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Shadow.res b/analysis/examples/larger-project/src/Shadow.res
new file mode 100644
index 000000000..7e6c5542a
--- /dev/null
+++ b/analysis/examples/larger-project/src/Shadow.res
@@ -0,0 +1,12 @@
+@genType
+let test = () => 3
+
+@genType
+let test = () => "a"
+
+module M = {
+ @genType
+ let test = () => 3
+
+ let test = () => "a"
+}
diff --git a/analysis/examples/larger-project/src/TestDeadExn.js b/analysis/examples/larger-project/src/TestDeadExn.js
new file mode 100644
index 000000000..5d949f4d8
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestDeadExn.js
@@ -0,0 +1,12 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as DeadExn from "./DeadExn.js";
+
+console.log({
+ RE_EXN_ID: DeadExn.Etoplevel
+ });
+
+export {
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/TestDeadExn.res b/analysis/examples/larger-project/src/TestDeadExn.res
new file mode 100644
index 000000000..b1569a222
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestDeadExn.res
@@ -0,0 +1 @@
+Js.log(DeadExn.Etoplevel)
diff --git a/analysis/examples/larger-project/src/TestEmitInnerModules.js b/analysis/examples/larger-project/src/TestEmitInnerModules.js
new file mode 100644
index 000000000..3d1c412ec
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestEmitInnerModules.js
@@ -0,0 +1,26 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var Inner = {
+ x: 34,
+ y: "hello"
+};
+
+var Inner$1 = {
+ y: 44
+};
+
+var Medium = {
+ Inner: Inner$1
+};
+
+var Outer = {
+ Medium: Medium
+};
+
+export {
+ Inner ,
+ Outer ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TestEmitInnerModules.res b/analysis/examples/larger-project/src/TestEmitInnerModules.res
new file mode 100644
index 000000000..eed5c4fe2
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestEmitInnerModules.res
@@ -0,0 +1,15 @@
+module Inner = {
+ @genType
+ let x = 34
+ @genType
+ let y = "hello"
+}
+
+module Outer = {
+ module Medium = {
+ module Inner = {
+ @genType
+ let y = 44
+ }
+ }
+}
diff --git a/analysis/examples/larger-project/src/TestFirstClassModules.js b/analysis/examples/larger-project/src/TestFirstClassModules.js
new file mode 100644
index 000000000..d09433ad8
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestFirstClassModules.js
@@ -0,0 +1,27 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function convert(x) {
+ return x;
+}
+
+function convertInterface(x) {
+ return x;
+}
+
+function convertRecord(x) {
+ return x;
+}
+
+function convertFirstClassModuleWithTypeEquations(x) {
+ return x;
+}
+
+export {
+ convert ,
+ convertInterface ,
+ convertRecord ,
+ convertFirstClassModuleWithTypeEquations ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TestFirstClassModules.res b/analysis/examples/larger-project/src/TestFirstClassModules.res
new file mode 100644
index 000000000..a799e858e
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestFirstClassModules.res
@@ -0,0 +1,30 @@
+@genType
+let convert = (x: FirstClassModules.firstClassModule) => x
+
+@genType
+let convertInterface = (x: FirstClassModulesInterface.firstClassModule) => x
+
+@genType
+let convertRecord = (x: FirstClassModulesInterface.record) => x
+
+module type MT = {
+ type outer
+ let out: outer => outer
+
+ module Inner: {
+ type inner
+ let inn: inner => inner
+ }
+}
+
+@genType
+type firstClassModuleWithTypeEquations<'i, 'o> = module(MT with
+ type Inner.inner = 'i
+ and type outer = 'o
+)
+
+@genType
+let convertFirstClassModuleWithTypeEquations = (
+ type o i,
+ x: module(MT with type Inner.inner = i and type outer = o),
+) => x
diff --git a/analysis/examples/larger-project/src/TestImmutableArray.js b/analysis/examples/larger-project/src/TestImmutableArray.js
new file mode 100644
index 000000000..105467807
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestImmutableArray.js
@@ -0,0 +1,24 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
+import * as Caml_array from "rescript/lib/es6/caml_array.js";
+
+function testImmutableArrayGet(arr) {
+ return Caml_array.get(arr, 3);
+}
+
+function testBeltArrayGet(arr) {
+ return Belt_Array.get(arr, 3);
+}
+
+function testBeltArraySet(arr) {
+ return Belt_Array.set(arr, 3, 4);
+}
+
+export {
+ testImmutableArrayGet ,
+ testBeltArrayGet ,
+ testBeltArraySet ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TestImmutableArray.res b/analysis/examples/larger-project/src/TestImmutableArray.res
new file mode 100644
index 000000000..d4b49b7a2
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestImmutableArray.res
@@ -0,0 +1,20 @@
+@genType
+let testImmutableArrayGet = arr => {
+ open ImmutableArray
+ arr[3]
+}
+
+/*
+ type error
+ let testImmutableArraySet = arr => ImmutableArray.(arr[3] = 4);
+ */
+
+let testBeltArrayGet = arr => {
+ open Belt
+ arr[3]
+}
+
+let testBeltArraySet = arr => {
+ open Belt
+ arr[3] = 4
+}
diff --git a/analysis/examples/larger-project/src/TestImport.js b/analysis/examples/larger-project/src/TestImport.js
new file mode 100644
index 000000000..f38c53dbf
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestImport.js
@@ -0,0 +1,29 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Caml_option from "rescript/lib/es6/caml_option.js";
+import * as TestImportGen from "./TestImport.gen";
+
+var innerStuffContents = TestImportGen.innerStuffContents;
+
+var innerStuffContentsAsEmptyObject = TestImportGen.innerStuffContentsAsEmptyObject;
+
+var valueStartingWithUpperCaseLetter = TestImportGen.valueStartingWithUpperCaseLetter;
+
+var defaultValue = TestImportGen.defaultValue;
+
+function make(prim0, prim1, prim2) {
+ return TestImportGen.make(prim0, prim1 !== undefined ? Caml_option.valFromOption(prim1) : undefined, prim2);
+}
+
+var defaultValue2 = TestImportGen.defaultValue2;
+
+export {
+ innerStuffContentsAsEmptyObject ,
+ innerStuffContents ,
+ valueStartingWithUpperCaseLetter ,
+ defaultValue ,
+ make ,
+ defaultValue2 ,
+
+}
+/* innerStuffContents Not a pure module */
diff --git a/analysis/examples/larger-project/src/TestImport.res b/analysis/examples/larger-project/src/TestImport.res
new file mode 100644
index 000000000..41d337165
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestImport.res
@@ -0,0 +1,30 @@
+@genType.import((
+ "./exportNestedValues",
+ "TopLevelClass.MiddleLevelElements.stuff.InnerStuff.innerStuffContents",
+))
+external innerStuffContents: {"x": int} = "innerStuffContents"
+
+@genType.import((
+ "./exportNestedValues",
+ "TopLevelClass.MiddleLevelElements.stuff.InnerStuff.innerStuffContents",
+))
+external innerStuffContentsAsEmptyObject: {.} = "innerStuffContentsAsEmptyObject"
+
+let innerStuffContents = innerStuffContents
+
+@genType.import(("./exportNestedValues", "ValueStartingWithUpperCaseLetter"))
+external valueStartingWithUpperCaseLetter: string = "valueStartingWithUpperCaseLetter"
+
+@genType.import(("./exportNestedValues", "default"))
+external defaultValue: int = "defaultValue"
+
+@genType
+type message = {text: string}
+
+@genType.import(("./MyBanner", "TopLevelClass.MiddleLevelElements.MyBannerInternal"))
+external make: (~show: bool, ~message: option=?, 'a) => React.element = "make"
+
+let make = make
+
+@genType.import(("./exportNestedValues", "default"))
+external defaultValue2: int = "defaultValue2"
diff --git a/analysis/examples/larger-project/src/TestModuleAliases.js b/analysis/examples/larger-project/src/TestModuleAliases.js
new file mode 100644
index 000000000..50564c7a0
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestModuleAliases.js
@@ -0,0 +1,45 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function testInner1(x) {
+ return x;
+}
+
+function testInner1Expanded(x) {
+ return x;
+}
+
+function testInner2(x) {
+ return x;
+}
+
+function testInner2Expanded(x) {
+ return x;
+}
+
+var OtherFile;
+
+var OtherFileAlias;
+
+var OuterAlias;
+
+var OtherFile1;
+
+var Outer2;
+
+var Inner2;
+
+export {
+ OtherFile ,
+ OtherFileAlias ,
+ OuterAlias ,
+ OtherFile1 ,
+ Outer2 ,
+ Inner2 ,
+ testInner1 ,
+ testInner1Expanded ,
+ testInner2 ,
+ testInner2Expanded ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TestModuleAliases.res b/analysis/examples/larger-project/src/TestModuleAliases.res
new file mode 100644
index 000000000..fff070c4b
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestModuleAliases.res
@@ -0,0 +1,41 @@
+module OtherFile = ModuleAliases2
+module OtherFileAlias = OtherFile
+
+@genType
+type record = OtherFile.record
+
+@genType
+type record2 = OtherFileAlias.record
+
+module OuterAlias = OtherFile.Outer
+
+@genType
+type outer = OtherFileAlias.Outer.outer
+
+@genType
+type outer2 = OuterAlias.outer
+
+module OtherFile1 = OtherFile
+module Outer2 = OtherFile1.Outer
+module Inner2 = Outer2.Inner
+
+@genType
+type my2 = Inner2.inner
+
+@genType
+type inner1 = OtherFile.InnerAlias.inner
+
+@genType
+type inner2 = OtherFile.Outer.Inner.inner
+
+@genType
+let testInner1 = (x: inner1) => x
+
+@genType
+let testInner1Expanded = (x: OtherFile.InnerAlias.inner) => x
+
+@genType
+let testInner2 = (x: inner2) => x
+
+@genType
+let testInner2Expanded = (x: OtherFile.Outer.Inner.inner) => x
diff --git a/analysis/examples/larger-project/src/TestOptArg.js b/analysis/examples/larger-project/src/TestOptArg.js
new file mode 100644
index 000000000..2369ece08
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestOptArg.js
@@ -0,0 +1,44 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as OptArg from "./OptArg.js";
+
+console.log(OptArg.bar(undefined, 3, 3, 4));
+
+function foo(xOpt, y) {
+ var x = xOpt !== undefined ? xOpt : 3;
+ return x + y | 0;
+}
+
+function bar(param) {
+ var x = 12;
+ return x + 3 | 0;
+}
+
+console.log(bar);
+
+function notSuppressesOptArgs(xOpt, yOpt, zOpt, w) {
+ var x = xOpt !== undefined ? xOpt : 1;
+ var y = yOpt !== undefined ? yOpt : 2;
+ var z = zOpt !== undefined ? zOpt : 3;
+ return ((x + y | 0) + z | 0) + w | 0;
+}
+
+notSuppressesOptArgs(undefined, undefined, undefined, 3);
+
+function liveSuppressesOptArgs(xOpt, yOpt, zOpt, w) {
+ var x = xOpt !== undefined ? xOpt : 1;
+ var y = yOpt !== undefined ? yOpt : 2;
+ var z = zOpt !== undefined ? zOpt : 3;
+ return ((x + y | 0) + z | 0) + w | 0;
+}
+
+liveSuppressesOptArgs(3, undefined, undefined, 3);
+
+export {
+ foo ,
+ bar ,
+ notSuppressesOptArgs ,
+ liveSuppressesOptArgs ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/TestOptArg.res b/analysis/examples/larger-project/src/TestOptArg.res
new file mode 100644
index 000000000..ef38c7c7e
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestOptArg.res
@@ -0,0 +1,16 @@
+Js.log(OptArg.bar(~z=3, ~y=3, 4))
+
+let foo = (~x=3, y) => x + y
+
+let bar = () => foo(~x=12, 3)
+
+Js.log(bar)
+
+let notSuppressesOptArgs = (~x=1, ~y=2, ~z=3, w) => x + y + z + w
+
+let _ = notSuppressesOptArgs(3)
+
+@live
+let liveSuppressesOptArgs = (~x=1, ~y=2, ~z=3, w) => x + y + z + w
+
+let _ = liveSuppressesOptArgs(~x=3, 3)
diff --git a/analysis/examples/larger-project/src/TestPromise.js b/analysis/examples/larger-project/src/TestPromise.js
new file mode 100644
index 000000000..0289ad50c
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestPromise.js
@@ -0,0 +1,16 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function convert(param) {
+ return param.then(function (param) {
+ return Promise.resolve({
+ result: param.s
+ });
+ });
+}
+
+export {
+ convert ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TestPromise.res b/analysis/examples/larger-project/src/TestPromise.res
new file mode 100644
index 000000000..acf835948
--- /dev/null
+++ b/analysis/examples/larger-project/src/TestPromise.res
@@ -0,0 +1,14 @@
+@genType
+type promise<'a> = Js.Promise.t<'a>
+
+@genType
+type fromPayload = {
+ x: int,
+ s: string,
+}
+
+@genType
+type toPayload = {result: string}
+
+@genType
+let convert = Js.Promise.then_(({s}) => Js.Promise.resolve({result: s}))
diff --git a/analysis/examples/larger-project/src/ToSuppress.js b/analysis/examples/larger-project/src/ToSuppress.js
new file mode 100644
index 000000000..b16279a28
--- /dev/null
+++ b/analysis/examples/larger-project/src/ToSuppress.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var toSuppress = 0;
+
+export {
+ toSuppress ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/ToSuppress.res b/analysis/examples/larger-project/src/ToSuppress.res
new file mode 100644
index 000000000..e21f46451
--- /dev/null
+++ b/analysis/examples/larger-project/src/ToSuppress.res
@@ -0,0 +1 @@
+let toSuppress = 0
diff --git a/analysis/examples/larger-project/src/TransitiveType1.js b/analysis/examples/larger-project/src/TransitiveType1.js
new file mode 100644
index 000000000..fb6d4e9f3
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType1.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function convert(x) {
+ return x;
+}
+
+function convertAlias(x) {
+ return x;
+}
+
+export {
+ convert ,
+ convertAlias ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TransitiveType1.res b/analysis/examples/larger-project/src/TransitiveType1.res
new file mode 100644
index 000000000..3d16c5e3b
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType1.res
@@ -0,0 +1,5 @@
+@genType
+let convert = (x: TransitiveType2.t2) => x
+
+@genType
+let convertAlias = (x: TransitiveType2.t2Alias) => x
diff --git a/analysis/examples/larger-project/src/TransitiveType2.js b/analysis/examples/larger-project/src/TransitiveType2.js
new file mode 100644
index 000000000..e0bcc1c48
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType2.js
@@ -0,0 +1,12 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function convertT2(x) {
+ return x;
+}
+
+export {
+ convertT2 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TransitiveType2.res b/analysis/examples/larger-project/src/TransitiveType2.res
new file mode 100644
index 000000000..a0adb8974
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType2.res
@@ -0,0 +1,7 @@
+@genType
+type t2 = option
+
+@genType
+type t2Alias = t2
+
+let convertT2 = (x: t2) => x
diff --git a/analysis/examples/larger-project/src/TransitiveType3.js b/analysis/examples/larger-project/src/TransitiveType3.js
new file mode 100644
index 000000000..c28c6fa11
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType3.js
@@ -0,0 +1,12 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function convertT3(x) {
+ return x;
+}
+
+export {
+ convertT3 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TransitiveType3.res b/analysis/examples/larger-project/src/TransitiveType3.res
new file mode 100644
index 000000000..0e561b0cb
--- /dev/null
+++ b/analysis/examples/larger-project/src/TransitiveType3.res
@@ -0,0 +1,8 @@
+@genType
+type t3 = {
+ i: int,
+ s: string,
+}
+
+@genType
+let convertT3 = (x: t3) => x
diff --git a/analysis/examples/larger-project/src/Tuples.js b/analysis/examples/larger-project/src/Tuples.js
new file mode 100644
index 000000000..3e1475545
--- /dev/null
+++ b/analysis/examples/larger-project/src/Tuples.js
@@ -0,0 +1,73 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
+
+function testTuple(param) {
+ return param[0] + param[1] | 0;
+}
+
+function computeArea(param) {
+ return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) {
+ return n;
+ })));
+}
+
+function computeAreaWithIdent(param) {
+ return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) {
+ return n;
+ })));
+}
+
+function computeAreaNoConverters(param) {
+ return Math.imul(param[0], param[1]);
+}
+
+function coord2d(x, y) {
+ return [
+ x,
+ y,
+ undefined
+ ];
+}
+
+function getFirstName(param) {
+ return param[0].name;
+}
+
+function marry(first, second) {
+ return [
+ first,
+ second
+ ];
+}
+
+function changeSecondAge(param) {
+ var second = param[1];
+ return [
+ param[0],
+ {
+ name: second.name,
+ age: second.age + 1 | 0
+ }
+ ];
+}
+
+var origin = [
+ 0,
+ 0,
+ 0
+];
+
+export {
+ testTuple ,
+ origin ,
+ computeArea ,
+ computeAreaWithIdent ,
+ computeAreaNoConverters ,
+ coord2d ,
+ getFirstName ,
+ marry ,
+ changeSecondAge ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Tuples.res b/analysis/examples/larger-project/src/Tuples.res
new file mode 100644
index 000000000..e38ce79a8
--- /dev/null
+++ b/analysis/examples/larger-project/src/Tuples.res
@@ -0,0 +1,49 @@
+open Belt
+
+@genType
+let testTuple = ((a, b)) => a + b
+
+@genType
+type coord = (int, int, option)
+
+@genType
+let origin = (0, 0, Some(0))
+
+@genType
+let computeArea = ((x, y, z)) => {
+ open Option
+ x * y * z->mapWithDefault(1, n => n)
+}
+
+@genType
+let computeAreaWithIdent = ((x, y, z): coord) => {
+ open Option
+ x * y * z->mapWithDefault(1, n => n)
+}
+
+@genType
+let computeAreaNoConverters = ((x: int, y: int)) => x * y
+
+@genType
+let coord2d = (x, y) => (x, y, None)
+
+@genType
+type coord2 = (int, int, Js.Nullable.t)
+
+@genType
+type person = {
+ name: string,
+ age: int,
+}
+
+@genType
+type couple = (person, person)
+
+@genType
+let getFirstName = ((first, _second): couple) => first.name
+
+@genType
+let marry = (first, second): couple => (first, second)
+
+@genType
+let changeSecondAge = ((first, second): couple): couple => (first, {...second, age: second.age + 1})
diff --git a/analysis/examples/larger-project/src/TypeParams1.js b/analysis/examples/larger-project/src/TypeParams1.js
new file mode 100644
index 000000000..32eae0619
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams1.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var exportSomething = 10;
+
+export {
+ exportSomething ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TypeParams1.res b/analysis/examples/larger-project/src/TypeParams1.res
new file mode 100644
index 000000000..2e51defff
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams1.res
@@ -0,0 +1,4 @@
+@gentype
+type ocaml_array<'a> = array<'a>
+
+let exportSomething = 10
diff --git a/analysis/examples/larger-project/src/TypeParams2.js b/analysis/examples/larger-project/src/TypeParams2.js
new file mode 100644
index 000000000..32eae0619
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams2.js
@@ -0,0 +1,10 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+var exportSomething = 10;
+
+export {
+ exportSomething ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TypeParams2.res b/analysis/examples/larger-project/src/TypeParams2.res
new file mode 100644
index 000000000..f6a2ec0b0
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams2.res
@@ -0,0 +1,10 @@
+@genType
+type item = {id: int}
+
+@genType
+type items = TypeParams1.ocaml_array-
+
+@genType
+type items2 = array
-
+
+let exportSomething = 10
diff --git a/analysis/examples/larger-project/src/TypeParams3.js b/analysis/examples/larger-project/src/TypeParams3.js
new file mode 100644
index 000000000..5cca982d8
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams3.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function test(x) {
+ return x;
+}
+
+function test2(x) {
+ return x;
+}
+
+export {
+ test ,
+ test2 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/TypeParams3.res b/analysis/examples/larger-project/src/TypeParams3.res
new file mode 100644
index 000000000..6fd004468
--- /dev/null
+++ b/analysis/examples/larger-project/src/TypeParams3.res
@@ -0,0 +1,5 @@
+@genType
+let test = (x: TypeParams2.items) => x
+
+@genType
+let test2 = (x: TypeParams2.items2) => x
diff --git a/analysis/examples/larger-project/src/Types.js b/analysis/examples/larger-project/src/Types.js
new file mode 100644
index 000000000..5931d70cb
--- /dev/null
+++ b/analysis/examples/larger-project/src/Types.js
@@ -0,0 +1,109 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as List from "rescript/lib/es6/list.js";
+import * as Curry from "rescript/lib/es6/curry.js";
+import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
+
+function swap(tree) {
+ return {
+ label: tree.label,
+ left: Belt_Option.map(tree.right, swap),
+ right: Belt_Option.map(tree.left, swap)
+ };
+}
+
+function selfRecursiveConverter(param) {
+ return param.self;
+}
+
+function mutuallyRecursiveConverter(param) {
+ return param.b;
+}
+
+function testFunctionOnOptionsAsArgument(a, foo) {
+ return Curry._1(foo, a);
+}
+
+function jsonStringify(prim) {
+ return JSON.stringify(prim);
+}
+
+function testConvertNull(x) {
+ return x;
+}
+
+var testMarshalFields = {
+ rec: "rec",
+ _switch: "_switch",
+ switch: "switch",
+ __: "__",
+ _: "_",
+ foo: "foo",
+ _foo: "_foo",
+ Uppercase: "Uppercase",
+ _Uppercase: "_Uppercase"
+};
+
+function setMatch(x) {
+ x.match = 34;
+
+}
+
+function testInstantiateTypeParameter(x) {
+ return x;
+}
+
+var currentTime = new Date();
+
+var optFunction = (function (param) {
+ return 3;
+ });
+
+var ObjectId = {};
+
+var someIntList = {
+ hd: 1,
+ tl: {
+ hd: 2,
+ tl: {
+ hd: 3,
+ tl: /* [] */0
+ }
+ }
+};
+
+var map = List.map;
+
+var stringT = "a";
+
+var jsStringT = "a";
+
+var jsString2T = "a";
+
+var i64Const = [
+ 0,
+ 34
+];
+
+export {
+ someIntList ,
+ map ,
+ swap ,
+ selfRecursiveConverter ,
+ mutuallyRecursiveConverter ,
+ testFunctionOnOptionsAsArgument ,
+ stringT ,
+ jsStringT ,
+ jsString2T ,
+ jsonStringify ,
+ testConvertNull ,
+ testMarshalFields ,
+ setMatch ,
+ testInstantiateTypeParameter ,
+ currentTime ,
+ i64Const ,
+ optFunction ,
+ ObjectId ,
+
+}
+/* currentTime Not a pure module */
diff --git a/analysis/examples/larger-project/src/Types.res b/analysis/examples/larger-project/src/Types.res
new file mode 100644
index 000000000..ee398c1ff
--- /dev/null
+++ b/analysis/examples/larger-project/src/Types.res
@@ -0,0 +1,167 @@
+@genType
+type t = int
+
+@genType
+let someIntList = list{1, 2, 3}
+
+@genType
+let map = List.map
+
+@genType
+type typeWithVars<'x, 'y, 'z> =
+ | A('x, 'y)
+ | B('z)
+
+@genType
+type rec tree = {"label": string, "left": option, "right": option}
+
+/*
+ * A tree is a recursive type which does not require any conversion (JS object).
+ * All is well.
+ */
+@genType
+let rec swap = (tree: tree): tree =>
+ {
+ "label": tree["label"],
+ "left": tree["right"]->Belt.Option.map(swap),
+ "right": tree["left"]->Belt.Option.map(swap),
+ }
+
+@genType
+type rec selfRecursive = {self: selfRecursive}
+
+@genType
+type rec mutuallyRecursiveA = {b: mutuallyRecursiveB}
+and mutuallyRecursiveB = {a: mutuallyRecursiveA}
+
+/*
+ * This is a recursive type which requires conversion (a record).
+ * Only a shallow conversion of the top-level element is performed.
+ */
+@genType
+let selfRecursiveConverter = ({self}) => self
+
+/*
+ * This is a mutually recursive type which requires conversion (a record).
+ * Only a shallow conversion of the two top-level elements is performed.
+ */
+@genType
+let mutuallyRecursiveConverter = ({b}) => b
+
+@genType
+let testFunctionOnOptionsAsArgument = (a: option<'a>, foo) => foo(a)
+
+@genType.opaque
+type opaqueVariant =
+ | A
+ | B
+
+@genType
+let stringT: String.t = "a"
+
+@genType
+let jsStringT: Js.String.t = "a"
+
+@genType
+let jsString2T: Js.String2.t = "a"
+
+@genType
+type twice<'a> = ('a, 'a)
+
+@gentype
+type genTypeMispelled = int
+
+@genType
+type dictString = Js.Dict.t
+
+@genType
+let jsonStringify = Js.Json.stringify
+
+@genType
+type nullOrString = Js.Null.t
+
+@genType
+type nullOrString2 = Js.null
+
+type record = {
+ i: int,
+ s: string,
+}
+
+@genType
+let testConvertNull = (x: Js.Null.t) => x
+
+@genType
+type decorator<'a, 'b> = 'a => 'b constraint 'a = int constraint 'b = _ => _
+
+/* Bucklescript's marshaling rules. */
+@genType
+type marshalFields = {
+ "_rec": string,
+ "_switch": string,
+ "switch": string,
+ "__": string,
+ "___": string,
+ "foo__": string,
+ "_foo__": string,
+ "_Uppercase": string,
+ "_Uppercase__": string,
+}
+
+@genType
+let testMarshalFields: marshalFields = {
+ "_rec": "rec",
+ "_switch" /* reason keywords are not recognized */: "_switch",
+ "switch": "switch",
+ "__": "__",
+ "___": "_",
+ "foo__": "foo",
+ "_foo__": "_foo",
+ "_Uppercase": "Uppercase",
+ "_Uppercase__": "_Uppercase",
+}
+
+@genType
+type marshalMutableField = {@set "_match": int}
+
+@genType
+let setMatch = (x: marshalMutableField) => x["_match"] = 34
+
+type ocaml_array<'a> = array<'a>
+
+// This should be considered annotated automatically.
+type someRecord = {id: int}
+
+type instantiateTypeParameter = ocaml_array
+
+@genType
+let testInstantiateTypeParameter = (x: instantiateTypeParameter) => x
+
+@genType @genType.as("Vector")
+type vector<'a> = ('a, 'a)
+
+@genType
+type date = Js.Date.t
+
+@genType
+let currentTime = Js.Date.make()
+
+@genType
+type i64A = Int64.t
+
+@genType
+type i64B = int64
+
+@genType
+let i64Const: i64B = 34L
+
+@genType
+let optFunction = Some(() => 3)
+
+module ObjectId: {
+ @genType
+ type t = int
+} = {
+ type t = int
+ let x = 1
+}
diff --git a/analysis/examples/larger-project/src/Unboxed.js b/analysis/examples/larger-project/src/Unboxed.js
new file mode 100644
index 000000000..ff72d52a5
--- /dev/null
+++ b/analysis/examples/larger-project/src/Unboxed.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function testV1(x) {
+ return x;
+}
+
+function r2Test(x) {
+ return x;
+}
+
+export {
+ testV1 ,
+ r2Test ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Unboxed.res b/analysis/examples/larger-project/src/Unboxed.res
new file mode 100644
index 000000000..fdc9c03bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/Unboxed.res
@@ -0,0 +1,17 @@
+@genType @ocaml.unboxed
+type v1 = A(int)
+
+@genType @unboxed
+type v2 = A(int)
+
+@genType
+let testV1 = (x: v1) => x
+
+@genType @unboxed
+type r1 = {x: int}
+
+@genType @ocaml.unboxed
+type r2 = B({g: string})
+
+@genType
+let r2Test = (x: r2) => x
diff --git a/analysis/examples/larger-project/src/Uncurried.js b/analysis/examples/larger-project/src/Uncurried.js
new file mode 100644
index 000000000..1ab585863
--- /dev/null
+++ b/analysis/examples/larger-project/src/Uncurried.js
@@ -0,0 +1,80 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Curry from "rescript/lib/es6/curry.js";
+
+function uncurried0() {
+ return "";
+}
+
+function uncurried1(x) {
+ return String(x);
+}
+
+function uncurried2(x, y) {
+ return String(x) + y;
+}
+
+function uncurried3(x, y, z) {
+ return String(x) + (y + String(z));
+}
+
+function curried3(x, y, z) {
+ return String(x) + (y + String(z));
+}
+
+function callback(cb) {
+ return String(Curry._1(cb, undefined));
+}
+
+function callback2(auth) {
+ return Curry._1(auth.login, undefined);
+}
+
+function callback2U(auth) {
+ return auth.loginU();
+}
+
+function sumU(n, m) {
+ console.log("sumU 2nd arg", m, "result", n + m | 0);
+
+}
+
+function sumU2(n) {
+ return function (m) {
+ console.log("sumU2 2nd arg", m, "result", n + m | 0);
+
+ };
+}
+
+function sumCurried(n) {
+ console.log("sumCurried 1st arg", n);
+ return function (m) {
+ console.log("sumCurried 2nd arg", m, "result", n + m | 0);
+
+ };
+}
+
+function sumLblCurried(s, n) {
+ console.log(s, "sumLblCurried 1st arg", n);
+ return function (m) {
+ console.log("sumLblCurried 2nd arg", m, "result", n + m | 0);
+
+ };
+}
+
+export {
+ uncurried0 ,
+ uncurried1 ,
+ uncurried2 ,
+ uncurried3 ,
+ curried3 ,
+ callback ,
+ callback2 ,
+ callback2U ,
+ sumU ,
+ sumU2 ,
+ sumCurried ,
+ sumLblCurried ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Uncurried.res b/analysis/examples/larger-project/src/Uncurried.res
new file mode 100644
index 000000000..641a8b6f6
--- /dev/null
+++ b/analysis/examples/larger-project/src/Uncurried.res
@@ -0,0 +1,56 @@
+@genType
+type u0 = (. unit) => string
+
+@genType
+type u1 = (. int) => string
+
+@genType
+type u2 = (. int, string) => string
+
+@genType
+type u3 = (. int, string, int) => string
+
+@genType
+let uncurried0 = (. ()) => ""
+
+@genType
+let uncurried1 = (. x) => x |> string_of_int
+
+@genType
+let uncurried2 = (. x, y) => (x |> string_of_int) ++ y
+
+@genType
+let uncurried3 = (. x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
+
+@genType
+let curried3 = (x, y, z) => (x |> string_of_int) ++ (y ++ (z |> string_of_int))
+
+@genType
+let callback = cb => cb() |> string_of_int
+
+type auth = {login: unit => string}
+type authU = {loginU: (. unit) => string}
+
+@genType
+let callback2 = auth => auth.login()
+
+@genType
+let callback2U = auth => auth.loginU(.)
+
+@genType
+let sumU = (. n, m) => Js.log4("sumU 2nd arg", m, "result", n + m)
+
+@genType
+let sumU2 = (. n, . m) => Js.log4("sumU2 2nd arg", m, "result", n + m)
+
+@genType
+let sumCurried = n => {
+ Js.log2("sumCurried 1st arg", n)
+ m => Js.log4("sumCurried 2nd arg", m, "result", n + m)
+}
+
+@genType
+let sumLblCurried = (s: string, ~n) => {
+ Js.log3(s, "sumLblCurried 1st arg", n)
+ (~m) => Js.log4("sumLblCurried 2nd arg", m, "result", n + m)
+}
diff --git a/analysis/examples/larger-project/src/Unison.js b/analysis/examples/larger-project/src/Unison.js
new file mode 100644
index 000000000..1be71e816
--- /dev/null
+++ b/analysis/examples/larger-project/src/Unison.js
@@ -0,0 +1,76 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function group(breakOpt, doc) {
+ var $$break = breakOpt !== undefined ? breakOpt : /* IfNeed */0;
+ return {
+ break: $$break,
+ doc: doc
+ };
+}
+
+function fits(_w, _stack) {
+ while(true) {
+ var stack = _stack;
+ var w = _w;
+ if (w < 0) {
+ return false;
+ }
+ if (!stack) {
+ return true;
+ }
+ _stack = stack._1;
+ _w = w - stack._0.doc.length | 0;
+ continue ;
+ };
+}
+
+function toString(width, stack) {
+ if (!stack) {
+ return "";
+ }
+ var stack$1 = stack._1;
+ var match = stack._0;
+ var doc = match.doc;
+ switch (match.break) {
+ case /* IfNeed */0 :
+ return (
+ fits(width, stack$1) ? "fits " : "no "
+ ) + toString(width - 1 | 0, stack$1);
+ case /* Never */1 :
+ return "never " + (doc + toString(width - 1 | 0, stack$1));
+ case /* Always */2 :
+ return "always " + (doc + toString(width - 1 | 0, stack$1));
+
+ }
+}
+
+toString(80, /* Empty */0);
+
+var $$break = /* Never */1;
+
+toString(80, /* Cons */{
+ _0: {
+ break: $$break,
+ doc: "abc"
+ },
+ _1: /* Empty */0
+ });
+
+var $$break$1 = /* Always */2;
+
+toString(80, /* Cons */{
+ _0: {
+ break: $$break$1,
+ doc: "d"
+ },
+ _1: /* Empty */0
+ });
+
+export {
+ group ,
+ fits ,
+ toString ,
+
+}
+/* Not a pure module */
diff --git a/analysis/examples/larger-project/src/Unison.res b/analysis/examples/larger-project/src/Unison.res
new file mode 100644
index 000000000..cfef1fa1d
--- /dev/null
+++ b/analysis/examples/larger-project/src/Unison.res
@@ -0,0 +1,39 @@
+// Exmple of several DCE checks operating in unison
+
+type break =
+ | IfNeed
+ | Never
+ | Always
+
+type t = {
+ break: break,
+ doc: string,
+}
+
+type rec stack =
+ | Empty
+ | Cons(t, stack)
+
+let group = (~break=IfNeed, doc) => {break: break, doc: doc}
+
+let rec fits = (w, stack) =>
+ switch stack {
+ | _ if w < 0 => false
+ | Empty => true
+ | Cons({doc}, stack) => fits(w - String.length(doc), stack)
+ }
+
+let rec toString = (~width, stack) =>
+ switch stack {
+ | Cons({break, doc}, stack) =>
+ switch break {
+ | IfNeed => (fits(width, stack) ? "fits " : "no ") ++ (stack |> toString(~width=width - 1))
+ | Never => "never " ++ (doc ++ (stack |> toString(~width=width - 1)))
+ | Always => "always " ++ (doc ++ (stack |> toString(~width=width - 1)))
+ }
+ | Empty => ""
+ }
+
+toString(~width=80, Empty)
+toString(~width=80, Cons(group(~break=Never, "abc"), Empty))
+toString(~width=80, Cons(group(~break=Always, "d"), Empty))
diff --git a/analysis/examples/larger-project/src/UseImportJsValue.js b/analysis/examples/larger-project/src/UseImportJsValue.js
new file mode 100644
index 000000000..45a04b55f
--- /dev/null
+++ b/analysis/examples/larger-project/src/UseImportJsValue.js
@@ -0,0 +1,17 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function useGetProp(x) {
+ return x.getProp() + 1 | 0;
+}
+
+function useTypeImportedInOtherModule(x) {
+ return x;
+}
+
+export {
+ useGetProp ,
+ useTypeImportedInOtherModule ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/UseImportJsValue.res b/analysis/examples/larger-project/src/UseImportJsValue.res
new file mode 100644
index 000000000..08d9aee52
--- /dev/null
+++ b/analysis/examples/larger-project/src/UseImportJsValue.res
@@ -0,0 +1,5 @@
+@genType
+let useGetProp = (x: ImportJsValue.AbsoluteValue.t) => x->ImportJsValue.AbsoluteValue.getProp + 1
+
+@genType
+let useTypeImportedInOtherModule = (x: ImportJsValue.stringFunction) => x
diff --git a/analysis/examples/larger-project/src/Variants.js b/analysis/examples/larger-project/src/Variants.js
new file mode 100644
index 000000000..925f33831
--- /dev/null
+++ b/analysis/examples/larger-project/src/Variants.js
@@ -0,0 +1,107 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function isWeekend(x) {
+ if (x === "sunday") {
+ return true;
+ } else {
+ return x === "saturday";
+ }
+}
+
+function onlySunday(param) {
+
+}
+
+function swap(x) {
+ if (x === "sunday") {
+ return "saturday";
+ } else {
+ return "sunday";
+ }
+}
+
+function testConvert(x) {
+ return x;
+}
+
+function testConvert2(x) {
+ return x;
+}
+
+function testConvert3(x) {
+ return x;
+}
+
+function testConvert2to3(x) {
+ return x;
+}
+
+function id1(x) {
+ return x;
+}
+
+function id2(x) {
+ return x;
+}
+
+function polyWithOpt(foo) {
+ if (foo === "bar") {
+ return ;
+ } else if (foo !== "baz") {
+ return {
+ NAME: "One",
+ VAL: foo
+ };
+ } else {
+ return {
+ NAME: "Two",
+ VAL: 1
+ };
+ }
+}
+
+function restResult1(x) {
+ return x;
+}
+
+function restResult2(x) {
+ return x;
+}
+
+function restResult3(x) {
+ return x;
+}
+
+var monday = "monday";
+
+var saturday = "saturday";
+
+var sunday = "sunday";
+
+var fortytwoOK = "fortytwo";
+
+var fortytwoBAD = "fortytwo";
+
+export {
+ isWeekend ,
+ monday ,
+ saturday ,
+ sunday ,
+ onlySunday ,
+ swap ,
+ testConvert ,
+ fortytwoOK ,
+ fortytwoBAD ,
+ testConvert2 ,
+ testConvert3 ,
+ testConvert2to3 ,
+ id1 ,
+ id2 ,
+ polyWithOpt ,
+ restResult1 ,
+ restResult2 ,
+ restResult3 ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/Variants.res b/analysis/examples/larger-project/src/Variants.res
new file mode 100644
index 000000000..247a883a6
--- /dev/null
+++ b/analysis/examples/larger-project/src/Variants.res
@@ -0,0 +1,118 @@
+@genType
+type weekday = [
+ | #monday
+ | #tuesday
+ | #wednesday
+ | #thursday
+ | #friday
+ | #saturday
+ | #sunday
+]
+
+@genType
+let isWeekend = (x: weekday) =>
+ switch x {
+ | #saturday
+ | #sunday => true
+ | _ => false
+ }
+
+@genType
+let monday = #monday
+@genType
+let saturday = #saturday
+@genType
+let sunday = #sunday
+
+@genType
+let onlySunday = (_: [#sunday]) => ()
+
+@genType
+let swap = x =>
+ switch x {
+ | #sunday => #saturday
+ | #saturday => #sunday
+ }
+
+@genType
+type testGenTypeAs = [
+ | @genType.as("type") #type_
+ | @genType.as("module") #module_
+ | @genType.as("42") #fortytwo
+]
+
+@genType
+let testConvert = (x: testGenTypeAs) => x
+
+@genType
+let fortytwoOK: testGenTypeAs = #fortytwo
+
+/* Exporting this is BAD: type inference means it's not mapped to "42" */
+@genType
+let fortytwoBAD = #fortytwo
+
+@genType
+type testGenTypeAs2 = [
+ | @genType.as("type") #type_
+ | @genType.as("module") #module_
+ | @genType.as("42") #fortytwo
+]
+
+/* Since testGenTypeAs2 is the same type as testGenTypeAs1,
+ share the conversion map. */
+@genType
+let testConvert2 = (x: testGenTypeAs2) => x
+
+@genType
+type testGenTypeAs3 = [
+ | @genType.as("type") #type_
+ | @genType.as("module") #module_
+ | @genType.as("THIS IS DIFFERENT") #fortytwo
+]
+
+/* Since testGenTypeAs3 has a different representation:
+ use a new conversion map. */
+@genType
+let testConvert3 = (x: testGenTypeAs3) => x
+
+/* This converts between testGenTypeAs2 and testGenTypeAs3 */
+@genType
+let testConvert2to3 = (x: testGenTypeAs2): testGenTypeAs3 => x
+
+@genType
+type x1 = [#x | @genType.as("same") #x1]
+
+@genType
+type x2 = [#x | @genType.as("same") #x2]
+
+@genType
+let id1 = (x: x1) => x
+
+@genType
+let id2 = (x: x2) => x
+
+@genType @genType.as("type")
+type type_ = | @genType.as("type") Type
+
+@genType
+let polyWithOpt = foo => foo === "bar" ? None : foo !== "baz" ? Some(#One(foo)) : Some(#Two(1))
+
+@genType
+type result1<'a, 'b> =
+ | Ok('a)
+ | Error('b)
+
+@genType
+type result2<'a, 'b> = result<'a, 'b>
+
+@genType
+type result3<'a, 'b> = Belt.Result.t<'a, 'b>
+
+@genType
+let restResult1 = (x: result1) => x
+
+@genType
+let restResult2 = (x: result2) => x
+
+@genType
+let restResult3 = (x: result3) => x
diff --git a/analysis/examples/larger-project/src/VariantsWithPayload.js b/analysis/examples/larger-project/src/VariantsWithPayload.js
new file mode 100644
index 000000000..a04a25a65
--- /dev/null
+++ b/analysis/examples/larger-project/src/VariantsWithPayload.js
@@ -0,0 +1,99 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+
+function testWithPayload(x) {
+ return x;
+}
+
+function printVariantWithPayload(x) {
+ if (typeof x !== "object") {
+ if (x === "a") {
+ console.log("printVariantWithPayload: a");
+ } else if (x === "b") {
+ console.log("printVariantWithPayload: b");
+ } else if (x === "Half") {
+ console.log("printVariantWithPayload: Half");
+ } else if (x === "True") {
+ console.log("printVariantWithPayload: True");
+ } else {
+ console.log("printVariantWithPayload: Twenty");
+ }
+ return ;
+ }
+ var payload = x.VAL;
+ console.log("printVariantWithPayload x:", payload.x, "y:", payload.y);
+
+}
+
+function testManyPayloads(x) {
+ return x;
+}
+
+function printManyPayloads(x) {
+ var variant = x.NAME;
+ if (variant === "two") {
+ var match = x.VAL;
+ console.log("printManyPayloads two:", match[0], match[1]);
+ return ;
+ }
+ if (variant === "three") {
+ var payload = x.VAL;
+ console.log("printManyPayloads x:", payload.x, "y:", payload.y);
+ return ;
+ }
+ console.log("printManyPayloads one:", x.VAL);
+
+}
+
+function testSimpleVariant(x) {
+ return x;
+}
+
+function testVariantWithPayloads(x) {
+ return x;
+}
+
+function printVariantWithPayloads(x) {
+ if (typeof x === "number") {
+ console.log("printVariantWithPayloads", "A");
+ return ;
+ }
+ switch (x.TAG | 0) {
+ case /* B */0 :
+ console.log("printVariantWithPayloads", "B(" + (String(x._0) + ")"));
+ return ;
+ case /* C */1 :
+ console.log("printVariantWithPayloads", "C(" + (String(x._0) + (", " + (String(x._1) + ")"))));
+ return ;
+ case /* D */2 :
+ var match = x._0;
+ console.log("printVariantWithPayloads", "D((" + (String(match[0]) + (", " + (String(match[1]) + "))"))));
+ return ;
+ case /* E */3 :
+ console.log("printVariantWithPayloads", "E(" + (String(x._0) + (", " + (x._1 + (", " + (String(x._2) + ")"))))));
+ return ;
+
+ }
+}
+
+function testVariant1Int(x) {
+ return x;
+}
+
+function testVariant1Object(x) {
+ return x;
+}
+
+export {
+ testWithPayload ,
+ printVariantWithPayload ,
+ testManyPayloads ,
+ printManyPayloads ,
+ testSimpleVariant ,
+ testVariantWithPayloads ,
+ printVariantWithPayloads ,
+ testVariant1Int ,
+ testVariant1Object ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/VariantsWithPayload.res b/analysis/examples/larger-project/src/VariantsWithPayload.res
new file mode 100644
index 000000000..2252fa3da
--- /dev/null
+++ b/analysis/examples/larger-project/src/VariantsWithPayload.res
@@ -0,0 +1,99 @@
+type payload = {
+ x: int,
+ y: option,
+}
+
+type withPayload = [
+ | #a
+ | @genType.as("bRenamed") #b
+ | @genType.as(true) #True
+ | @genType.as(20) #Twenty
+ | @genType.as(0.5) #Half
+ | #c(payload)
+]
+
+@genType
+let testWithPayload = (x: withPayload) => x
+
+@genType
+let printVariantWithPayload = (x: withPayload) =>
+ switch x {
+ | #a => Js.log("printVariantWithPayload: a")
+ | #b => Js.log("printVariantWithPayload: b")
+ | #True => Js.log("printVariantWithPayload: True")
+ | #Twenty => Js.log("printVariantWithPayload: Twenty")
+ | #Half => Js.log("printVariantWithPayload: Half")
+ | #c(payload) => Js.log4("printVariantWithPayload x:", payload.x, "y:", payload.y)
+ }
+
+@genType
+type manyPayloads = [
+ | @genType.as("oneRenamed") #one(int)
+ | @genType.as(2) #two(string, string)
+ | #three(payload)
+]
+
+@genType
+let testManyPayloads = (x: manyPayloads) => x
+
+@genType
+let printManyPayloads = (x: manyPayloads) =>
+ switch x {
+ | #one(n) => Js.log2("printManyPayloads one:", n)
+ | #two(s1, s2) => Js.log3("printManyPayloads two:", s1, s2)
+ | #three(payload) => Js.log4("printManyPayloads x:", payload.x, "y:", payload.y)
+ }
+
+@genType
+type simpleVariant =
+ | A
+ | B
+ | C
+
+@genType
+let testSimpleVariant = (x: simpleVariant) => x
+
+@genType
+type variantWithPayloads =
+ | @genType.as("ARenamed") A
+ | B(int)
+ | C(int, int)
+ | D((int, int))
+ | E(int, string, int)
+
+@genType
+let testVariantWithPayloads = (x: variantWithPayloads) => x
+
+@genType
+let printVariantWithPayloads = x =>
+ switch x {
+ | A => Js.log2("printVariantWithPayloads", "A")
+ | B(x) => Js.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")"))
+ | C(x, y) =>
+ Js.log2(
+ "printVariantWithPayloads",
+ "C(" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ ")"))),
+ )
+ | D((x, y)) =>
+ Js.log2(
+ "printVariantWithPayloads",
+ "D((" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ "))"))),
+ )
+ | E(x, s, y) =>
+ Js.log2(
+ "printVariantWithPayloads",
+ "E(" ++ (string_of_int(x) ++ (", " ++ (s ++ (", " ++ (string_of_int(y) ++ ")"))))),
+ )
+ }
+
+@genType
+type variant1Int = R(int)
+
+@genType
+let testVariant1Int = (x: variant1Int) => x
+
+@genType
+type variant1Object = R(payload)
+
+@genType
+let testVariant1Object = (x: variant1Object) => x
diff --git a/analysis/examples/larger-project/src/arg_helper.js b/analysis/examples/larger-project/src/arg_helper.js
new file mode 100644
index 000000000..5503f1718
--- /dev/null
+++ b/analysis/examples/larger-project/src/arg_helper.js
@@ -0,0 +1,244 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as List from "rescript/lib/es6/list.js";
+import * as Curry from "rescript/lib/es6/curry.js";
+import * as Printf from "rescript/lib/es6/printf.js";
+import * as $$String from "rescript/lib/es6/string.js";
+import * as Printexc from "rescript/lib/es6/printexc.js";
+import * as Pervasives from "rescript/lib/es6/pervasives.js";
+import * as Caml_option from "rescript/lib/es6/caml_option.js";
+import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
+import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
+
+function fatal(err) {
+ console.error(err);
+ return Pervasives.exit(2);
+}
+
+function Make(S) {
+ var $$default = function (v) {
+ return {
+ base_default: v,
+ base_override: S.Key.$$Map.empty,
+ user_default: undefined,
+ user_override: S.Key.$$Map.empty
+ };
+ };
+ var set_base_default = function (value, t) {
+ return {
+ base_default: value,
+ base_override: t.base_override,
+ user_default: t.user_default,
+ user_override: t.user_override
+ };
+ };
+ var add_base_override = function (key, value, t) {
+ return {
+ base_default: t.base_default,
+ base_override: Curry._3(S.Key.$$Map.add, key, value, t.base_override),
+ user_default: t.user_default,
+ user_override: t.user_override
+ };
+ };
+ var reset_base_overrides = function (t) {
+ return {
+ base_default: t.base_default,
+ base_override: S.Key.$$Map.empty,
+ user_default: t.user_default,
+ user_override: t.user_override
+ };
+ };
+ var set_user_default = function (value, t) {
+ return {
+ base_default: t.base_default,
+ base_override: t.base_override,
+ user_default: Caml_option.some(value),
+ user_override: t.user_override
+ };
+ };
+ var add_user_override = function (key, value, t) {
+ return {
+ base_default: t.base_default,
+ base_override: t.base_override,
+ user_default: t.user_default,
+ user_override: Curry._3(S.Key.$$Map.add, key, value, t.user_override)
+ };
+ };
+ var Parse_failure = /* @__PURE__ */Caml_exceptions.create("Arg_helper.Make(S).Parse_failure");
+ var parse_exn = function (str, update) {
+ var values = List.filter(function (param) {
+ return "" !== param;
+ })($$String.split_on_char(/* ',' */44, str));
+ var parsed = List.fold_left((function (acc, value) {
+ var equals;
+ try {
+ equals = $$String.index(value, /* '=' */61);
+ }
+ catch (raw_exn){
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
+ if (exn.RE_EXN_ID === "Not_found") {
+ var exit = 0;
+ var value$1;
+ try {
+ value$1 = Curry._1(S.Value.of_string, value);
+ exit = 2;
+ }
+ catch (raw_exn$1){
+ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1);
+ throw {
+ RE_EXN_ID: Parse_failure,
+ _1: exn$1,
+ Error: new Error()
+ };
+ }
+ if (exit === 2) {
+ return set_user_default(value$1, acc);
+ }
+
+ } else {
+ throw exn;
+ }
+ }
+ var length = value.length;
+ if (!(equals >= 0 && equals < length)) {
+ throw {
+ RE_EXN_ID: "Assert_failure",
+ _1: [
+ "arg_helper.res",
+ 84,
+ 8
+ ],
+ Error: new Error()
+ };
+ }
+ if (equals === 0) {
+ throw {
+ RE_EXN_ID: Parse_failure,
+ _1: {
+ RE_EXN_ID: "Failure",
+ _1: "Missing key in argument specification"
+ },
+ Error: new Error()
+ };
+ }
+ var key = $$String.sub(value, 0, equals);
+ var key$1;
+ try {
+ key$1 = Curry._1(S.Key.of_string, key);
+ }
+ catch (raw_exn$2){
+ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2);
+ throw {
+ RE_EXN_ID: Parse_failure,
+ _1: exn$2,
+ Error: new Error()
+ };
+ }
+ var value$2 = $$String.sub(value, equals + 1 | 0, (length - equals | 0) - 1 | 0);
+ var value$3;
+ try {
+ value$3 = Curry._1(S.Value.of_string, value$2);
+ }
+ catch (raw_exn$3){
+ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3);
+ throw {
+ RE_EXN_ID: Parse_failure,
+ _1: exn$3,
+ Error: new Error()
+ };
+ }
+ return add_user_override(key$1, value$3, acc);
+ }), update.contents, values);
+ update.contents = parsed;
+
+ };
+ var parse = function (str, help_text, update) {
+ try {
+ parse_exn(str, update);
+ return ;
+ }
+ catch (raw_exn){
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
+ if (exn.RE_EXN_ID === Parse_failure) {
+ return fatal(Curry._2(Printf.sprintf(/* Format */{
+ _0: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: {
+ TAG: /* String_literal */11,
+ _0: ": ",
+ _1: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: /* End_of_format */0
+ }
+ }
+ },
+ _1: "%s: %s"
+ }), Printexc.to_string(exn._1), help_text));
+ }
+ throw exn;
+ }
+ };
+ var parse_no_error = function (str, update) {
+ try {
+ parse_exn(str, update);
+ return /* Ok */0;
+ }
+ catch (raw_exn){
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
+ if (exn.RE_EXN_ID === Parse_failure) {
+ return /* Parse_failed */{
+ _0: exn._1
+ };
+ }
+ throw exn;
+ }
+ };
+ var get = function (key, parsed) {
+ try {
+ return Curry._2(S.Key.$$Map.find, key, parsed.user_override);
+ }
+ catch (raw_exn){
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
+ if (exn.RE_EXN_ID === "Not_found") {
+ var value = parsed.user_default;
+ if (value !== undefined) {
+ return Caml_option.valFromOption(value);
+ }
+ try {
+ return Curry._2(S.Key.$$Map.find, key, parsed.base_override);
+ }
+ catch (raw_exn$1){
+ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1);
+ if (exn$1.RE_EXN_ID === "Not_found") {
+ return parsed.base_default;
+ }
+ throw exn$1;
+ }
+ } else {
+ throw exn;
+ }
+ }
+ };
+ return {
+ $$default: $$default,
+ set_base_default: set_base_default,
+ add_base_override: add_base_override,
+ reset_base_overrides: reset_base_overrides,
+ set_user_default: set_user_default,
+ add_user_override: add_user_override,
+ Parse_failure: Parse_failure,
+ parse_exn: parse_exn,
+ parse: parse,
+ parse_no_error: parse_no_error,
+ get: get
+ };
+}
+
+export {
+ fatal ,
+ Make ,
+
+}
+/* No side effect */
diff --git a/analysis/examples/larger-project/src/arg_helper.res b/analysis/examples/larger-project/src/arg_helper.res
new file mode 100644
index 000000000..898906c6d
--- /dev/null
+++ b/analysis/examples/larger-project/src/arg_helper.res
@@ -0,0 +1,142 @@
+/* ************************************************************************ */
+/* */
+/* OCaml */
+/* */
+/* Pierre Chambart, OCamlPro */
+/* Mark Shinwell and Leo White, Jane Street Europe */
+/* */
+/* Copyright 2015--2016 OCamlPro SAS */
+/* Copyright 2015--2016 Jane Street Group LLC */
+/* */
+/* All rights reserved. This file is distributed under the terms of */
+/* the GNU Lesser General Public License version 2.1, with the */
+/* special exception on linking described in the file LICENSE. */
+/* */
+/* ************************************************************************ */
+
+@raises(exit)
+let fatal = err => {
+ prerr_endline(err)
+ exit(2)
+}
+
+module Make = (
+ S: {
+ module Key: {
+ type t
+ let of_string: string => t
+ module Map: Map.S with type key = t
+ }
+
+ module Value: {
+ type t
+ let of_string: string => t
+ }
+ },
+) => {
+ type parsed = {
+ base_default: S.Value.t,
+ base_override: S.Key.Map.t,
+ user_default: option,
+ user_override: S.Key.Map.t,
+ }
+
+ let default = v => {
+ base_default: v,
+ base_override: S.Key.Map.empty,
+ user_default: None,
+ user_override: S.Key.Map.empty,
+ }
+
+ let set_base_default = (value, t) => {...t, base_default: value}
+
+ let add_base_override = (key, value, t) => {
+ ...t,
+ base_override: S.Key.Map.add(key, value, t.base_override),
+ }
+
+ let reset_base_overrides = t => {...t, base_override: S.Key.Map.empty}
+
+ let set_user_default = (value, t) => {...t, user_default: Some(value)}
+
+ let add_user_override = (key, value, t) => {
+ ...t,
+ user_override: S.Key.Map.add(key, value, t.user_override),
+ }
+
+ exception Parse_failure(exn)
+
+ @raises([Invalid_argument, Parse_failure])
+ let parse_exn = (str, ~update) => {
+ /* Is the removal of empty chunks really relevant here? */
+ /* (It has been added to mimic the old Misc.String.split.) */
+ let values = String.split_on_char(',', str) |> List.filter(\"<>"(""))
+ let parsed = List.fold_left((acc, value) =>
+ switch String.index(value, '=') {
+ | exception Not_found =>
+ switch S.Value.of_string(value) {
+ | value => set_user_default(value, acc)
+ | exception exn => raise(Parse_failure(exn))
+ }
+ | equals =>
+ let key_value_pair = value
+ let length = String.length(key_value_pair)
+ assert (equals >= 0 && equals < length)
+ if equals == 0 {
+ raise(Parse_failure(Failure("Missing key in argument specification")))
+ }
+ let key = {
+ let key = String.sub(key_value_pair, 0, equals)
+ try S.Key.of_string(key) catch {
+ | exn => raise(Parse_failure(exn))
+ }
+ }
+
+ let value = {
+ let value = String.sub(key_value_pair, equals + 1, length - equals - 1)
+
+ try S.Value.of_string(value) catch {
+ | exn => raise(Parse_failure(exn))
+ }
+ }
+
+ add_user_override(key, value, acc)
+ }
+ , update.contents, values)
+
+ update := parsed
+ }
+
+ @raises([Invalid_argument, exit])
+ let parse = (str, help_text, update) =>
+ switch parse_exn(str, ~update) {
+ | () => ()
+ | exception Parse_failure(exn) =>
+ fatal(Printf.sprintf("%s: %s", Printexc.to_string(exn), help_text))
+ }
+
+ type parse_result =
+ | Ok
+ | Parse_failed(exn)
+
+ @raises(Invalid_argument)
+ let parse_no_error = (str, update) =>
+ switch parse_exn(str, ~update) {
+ | () => Ok
+ | exception Parse_failure(exn) => Parse_failed(exn)
+ }
+
+ let get = (~key, parsed) =>
+ switch S.Key.Map.find(key, parsed.user_override) {
+ | value => value
+ | exception Not_found =>
+ switch parsed.user_default {
+ | Some(value) => value
+ | None =>
+ switch S.Key.Map.find(key, parsed.base_override) {
+ | value => value
+ | exception Not_found => parsed.base_default
+ }
+ }
+ }
+}
diff --git a/analysis/examples/larger-project/src/ast_helper.js b/analysis/examples/larger-project/src/ast_helper.js
new file mode 100644
index 000000000..a74aa6d85
--- /dev/null
+++ b/analysis/examples/larger-project/src/ast_helper.js
@@ -0,0 +1,53 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as $$Location from "./location.js";
+import * as Syntaxerr from "./syntaxerr.js";
+
+throw {
+ RE_EXN_ID: "Assert_failure",
+ _1: [
+ "ast_helper.res",
+ 23,
+ 21
+ ],
+ Error: new Error()
+ };
+
+export {
+ docstring_body ,
+ docstring_loc ,
+ text_attr ,
+ empty_docs ,
+ add_docs_attrs ,
+ add_text_attrs ,
+ empty_info ,
+ add_info_attrs ,
+ default_loc ,
+ with_default_loc ,
+ Const ,
+ Typ ,
+ Pat ,
+ Exp ,
+ Mty ,
+ Mod ,
+ Sig ,
+ Str ,
+ Cl ,
+ Cty ,
+ Ctf ,
+ Cf ,
+ Val ,
+ Md ,
+ Mtd ,
+ Mb ,
+ Opn ,
+ Incl ,
+ Vb ,
+ Ci ,
+ Type ,
+ Te ,
+ Csig ,
+ Cstr ,
+
+}
+/* docstring_body Not a pure module */
diff --git a/analysis/examples/larger-project/src/ast_helper.res b/analysis/examples/larger-project/src/ast_helper.res
new file mode 100644
index 000000000..fa5c7cb59
--- /dev/null
+++ b/analysis/examples/larger-project/src/ast_helper.res
@@ -0,0 +1,628 @@
+@@ocaml.text(
+ /* ************************************************************************ */
+ /* */
+ /* OCaml */
+ /* */
+ /* Alain Frisch, LexiFi */
+ /* */
+ /* Copyright 2012 Institut National de Recherche en Informatique et */
+ /* en Automatique. */
+ /* */
+ /* All rights reserved. This file is distributed under the terms of */
+ /* the GNU Lesser General Public License version 2.1, with the */
+ /* special exception on linking described in the file LICENSE. */
+ /* */
+ /* ************************************************************************ */
+
+ " Helpers to produce Parsetree fragments "
+)
+
+open Asttypes
+open Parsetree
+open Docstrings
+let docstring_body = assert false
+let docstring_loc = assert false
+let text_attr = assert false
+let empty_docs = assert false
+let add_docs_attrs = assert false
+let add_text_attrs = assert false
+let empty_info = assert false
+let add_info_attrs = assert false
+
+type lid = loc
+type str = loc
+type loc = Location.t
+type attrs = list
+
+let default_loc = ref(Location.none)
+
+@raises(genericException)
+let with_default_loc = (l, f) => {
+ let old = default_loc.contents
+ default_loc := l
+ try {
+ let r = f()
+ default_loc := old
+ r
+ } catch {
+ | exn =>
+ default_loc := old
+ raise(exn)
+ }
+}
+
+module Const = {
+ let integer = (~suffix=?, i) => Pconst_integer(i, suffix)
+ let int = (~suffix=?, i) => integer(~suffix?, string_of_int(i))
+ let int32 = (~suffix='l', i) => integer(~suffix, Int32.to_string(i))
+ let int64 = (~suffix='L', i) => integer(~suffix, Int64.to_string(i))
+ let nativeint = (~suffix='n', i) => integer(~suffix, Nativeint.to_string(i))
+ let float = (~suffix=?, f) => Pconst_float(f, suffix)
+ let char = c => Pconst_char(c)
+ let string = (~quotation_delimiter=?, s) => Pconst_string(s, quotation_delimiter)
+}
+
+module Typ = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ ptyp_desc: d,
+ ptyp_loc: loc,
+ ptyp_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, ptyp_attributes: \"@"(d.ptyp_attributes, list{a})}
+
+ let any = (~loc=?, ~attrs=?, ()) => mk(~loc?, ~attrs?, Ptyp_any)
+ let var = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ptyp_var(a))
+ let arrow = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Ptyp_arrow(a, b, c))
+ let tuple = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ptyp_tuple(a))
+ let constr = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_constr(a, b))
+ let object_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_object(a, b))
+ let class_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_class(a, b))
+ let alias = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_alias(a, b))
+ let variant = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Ptyp_variant(a, b, c))
+ let poly = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_poly(a, b))
+ let package = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ptyp_package(a, b))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ptyp_extension(a))
+
+ let force_poly = t =>
+ switch t.ptyp_desc {
+ | Ptyp_poly(_) => t
+ | _ => poly(~loc=t.ptyp_loc, list{}, t)
+ } /* -> ghost? */
+
+ @raises(Error)
+ let varify_constructors = (var_names, t) => {
+ @raises(Error)
+ let check_variable = (vl, loc, v) =>
+ if List.mem(v, vl) {
+ raise({
+ open Syntaxerr
+ Error(Variable_in_scope(loc, v))
+ })
+ }
+ let var_names = List.map(v => v.txt, var_names)
+
+ @raises(Error)
+ let rec loop = t => {
+ let desc = switch t.ptyp_desc {
+ | Ptyp_any => Ptyp_any
+ | Ptyp_var(x) =>
+ check_variable(var_names, t.ptyp_loc, x)
+ Ptyp_var(x)
+ | Ptyp_arrow(label, core_type, core_type') =>
+ Ptyp_arrow(label, loop(core_type), loop(core_type'))
+ | Ptyp_tuple(lst) => Ptyp_tuple(List.map(loop, lst))
+ | Ptyp_constr({txt: Longident.Lident(s)}, list{}) if List.mem(s, var_names) => Ptyp_var(s)
+ | Ptyp_constr(longident, lst) => Ptyp_constr(longident, List.map(loop, lst))
+ | Ptyp_object(lst, o) => Ptyp_object(List.map(loop_object_field, lst), o)
+ | Ptyp_class(longident, lst) => Ptyp_class(longident, List.map(loop, lst))
+ | Ptyp_alias(core_type, string) =>
+ check_variable(var_names, t.ptyp_loc, string)
+ Ptyp_alias(loop(core_type), string)
+ | Ptyp_variant(row_field_list, flag, lbl_lst_option) =>
+ Ptyp_variant(List.map(loop_row_field, row_field_list), flag, lbl_lst_option)
+ | Ptyp_poly(string_lst, core_type) =>
+ List.iter(v => check_variable(var_names, t.ptyp_loc, v.txt), string_lst)
+ Ptyp_poly(string_lst, loop(core_type))
+ | Ptyp_package(longident, lst) =>
+ Ptyp_package(longident, List.map(((n, typ)) => (n, loop(typ)), lst))
+ | Ptyp_extension(s, arg) => Ptyp_extension(s, arg)
+ }
+
+ {...t, ptyp_desc: desc}
+ }
+ @raises(Error)
+ and loop_row_field = x =>
+ switch x {
+ | Rtag(label, attrs, flag, lst) => Rtag(label, attrs, flag, List.map(loop, lst))
+ | Rinherit(t) => Rinherit(loop(t))
+ }
+ @raises(Error)
+ and loop_object_field = x =>
+ switch x {
+ | Otag(label, attrs, t) => Otag(label, attrs, loop(t))
+ | Oinherit(t) => Oinherit(loop(t))
+ }
+
+ loop(t)
+ }
+}
+
+module Pat = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ ppat_desc: d,
+ ppat_loc: loc,
+ ppat_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, ppat_attributes: \"@"(d.ppat_attributes, list{a})}
+
+ let any = (~loc=?, ~attrs=?, ()) => mk(~loc?, ~attrs?, Ppat_any)
+ let var = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_var(a))
+ let alias = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_alias(a, b))
+ let constant = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_constant(a))
+ let interval = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_interval(a, b))
+ let tuple = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_tuple(a))
+ let construct = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_construct(a, b))
+ let variant = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_variant(a, b))
+ let record = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_record(a, b))
+ let array = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_array(a))
+ let or_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_or(a, b))
+ let constraint_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_constraint(a, b))
+ let type_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_type(a))
+ let lazy_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_lazy(a))
+ let unpack = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_unpack(a))
+ let open_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Ppat_open(a, b))
+ let exception_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_exception(a))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Ppat_extension(a))
+}
+
+module Exp = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ pexp_desc: d,
+ pexp_loc: loc,
+ pexp_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, pexp_attributes: \"@"(d.pexp_attributes, list{a})}
+
+ let ident = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_ident(a))
+ let constant = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_constant(a))
+ let let_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_let(a, b, c))
+ let fun_ = (~loc=?, ~attrs=?, a, b, c, d) => mk(~loc?, ~attrs?, Pexp_fun(a, b, c, d))
+ let function_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_function(a))
+ let apply = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_apply(a, b))
+ let match_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_match(a, b))
+ let try_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_try(a, b))
+ let tuple = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_tuple(a))
+ let construct = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_construct(a, b))
+ let variant = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_variant(a, b))
+ let record = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_record(a, b))
+ let field = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_field(a, b))
+ let setfield = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_setfield(a, b, c))
+ let array = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_array(a))
+ let ifthenelse = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_ifthenelse(a, b, c))
+ let sequence = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_sequence(a, b))
+ let while_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_while(a, b))
+ let for_ = (~loc=?, ~attrs=?, a, b, c, d, e) => mk(~loc?, ~attrs?, Pexp_for(a, b, c, d, e))
+ let constraint_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_constraint(a, b))
+ let coerce = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_coerce(a, b, c))
+ let send = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_send(a, b))
+ let new_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_new(a))
+ let setinstvar = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_setinstvar(a, b))
+ let override = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_override(a))
+ let letmodule = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_letmodule(a, b, c))
+ let letexception = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_letexception(a, b))
+ let assert_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_assert(a))
+ let lazy_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_lazy(a))
+ let poly = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_poly(a, b))
+ let object_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_object(a))
+ let newtype = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pexp_newtype(a, b))
+ let pack = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_pack(a))
+ let open_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pexp_open(a, b, c))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pexp_extension(a))
+ let unreachable = (~loc=?, ~attrs=?, ()) => mk(~loc?, ~attrs?, Pexp_unreachable)
+
+ let case = (lhs, ~guard=?, rhs) => {
+ pc_lhs: lhs,
+ pc_guard: guard,
+ pc_rhs: rhs,
+ }
+}
+
+module Mty = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ pmty_desc: d,
+ pmty_loc: loc,
+ pmty_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, pmty_attributes: \"@"(d.pmty_attributes, list{a})}
+
+ let ident = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmty_ident(a))
+ let alias = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmty_alias(a))
+ let signature = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmty_signature(a))
+ let functor_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pmty_functor(a, b, c))
+ let with_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pmty_with(a, b))
+ let typeof_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmty_typeof(a))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmty_extension(a))
+}
+
+module Mod = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ pmod_desc: d,
+ pmod_loc: loc,
+ pmod_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, pmod_attributes: \"@"(d.pmod_attributes, list{a})}
+
+ let ident = (~loc=?, ~attrs=?, x) => mk(~loc?, ~attrs?, Pmod_ident(x))
+ let structure = (~loc=?, ~attrs=?, x) => mk(~loc?, ~attrs?, Pmod_structure(x))
+ let functor_ = (~loc=?, ~attrs=?, arg, arg_ty, body) =>
+ mk(~loc?, ~attrs?, Pmod_functor(arg, arg_ty, body))
+ let apply = (~loc=?, ~attrs=?, m1, m2) => mk(~loc?, ~attrs?, Pmod_apply(m1, m2))
+ let constraint_ = (~loc=?, ~attrs=?, m, mty) => mk(~loc?, ~attrs?, Pmod_constraint(m, mty))
+ let unpack = (~loc=?, ~attrs=?, e) => mk(~loc?, ~attrs?, Pmod_unpack(e))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pmod_extension(a))
+}
+
+module Sig = {
+ let mk = (~loc=default_loc.contents, d) => {psig_desc: d, psig_loc: loc}
+
+ let value = (~loc=?, a) => mk(~loc?, Psig_value(a))
+ let type_ = (~loc=?, rec_flag, a) => mk(~loc?, Psig_type(rec_flag, a))
+ let type_extension = (~loc=?, a) => mk(~loc?, Psig_typext(a))
+ let exception_ = (~loc=?, a) => mk(~loc?, Psig_exception(a))
+ let module_ = (~loc=?, a) => mk(~loc?, Psig_module(a))
+ let rec_module = (~loc=?, a) => mk(~loc?, Psig_recmodule(a))
+ let modtype = (~loc=?, a) => mk(~loc?, Psig_modtype(a))
+ let open_ = (~loc=?, a) => mk(~loc?, Psig_open(a))
+ let include_ = (~loc=?, a) => mk(~loc?, Psig_include(a))
+ let class_ = (~loc=?, a) => mk(~loc?, Psig_class(a))
+ let class_type = (~loc=?, a) => mk(~loc?, Psig_class_type(a))
+ let extension = (~loc=?, ~attrs=list{}, a) => mk(~loc?, Psig_extension(a, attrs))
+ let attribute = (~loc=?, a) => mk(~loc?, Psig_attribute(a))
+ let text = txt => {
+ let f_txt = List.filter(ds => docstring_body(ds) != "", txt)
+ List.map(ds => attribute(~loc=docstring_loc(ds), text_attr(ds)), f_txt)
+ }
+}
+
+module Str = {
+ let mk = (~loc=default_loc.contents, d) => {pstr_desc: d, pstr_loc: loc}
+
+ let eval = (~loc=?, ~attrs=list{}, a) => mk(~loc?, Pstr_eval(a, attrs))
+ let value = (~loc=?, a, b) => mk(~loc?, Pstr_value(a, b))
+ let primitive = (~loc=?, a) => mk(~loc?, Pstr_primitive(a))
+ let type_ = (~loc=?, rec_flag, a) => mk(~loc?, Pstr_type(rec_flag, a))
+ let type_extension = (~loc=?, a) => mk(~loc?, Pstr_typext(a))
+ let exception_ = (~loc=?, a) => mk(~loc?, Pstr_exception(a))
+ let module_ = (~loc=?, a) => mk(~loc?, Pstr_module(a))
+ let rec_module = (~loc=?, a) => mk(~loc?, Pstr_recmodule(a))
+ let modtype = (~loc=?, a) => mk(~loc?, Pstr_modtype(a))
+ let open_ = (~loc=?, a) => mk(~loc?, Pstr_open(a))
+ let class_ = (~loc=?, a) => mk(~loc?, Pstr_class(a))
+ let class_type = (~loc=?, a) => mk(~loc?, Pstr_class_type(a))
+ let include_ = (~loc=?, a) => mk(~loc?, Pstr_include(a))
+ let extension = (~loc=?, ~attrs=list{}, a) => mk(~loc?, Pstr_extension(a, attrs))
+ let attribute = (~loc=?, a) => mk(~loc?, Pstr_attribute(a))
+ let text = txt => {
+ let f_txt = List.filter(ds => docstring_body(ds) != "", txt)
+ List.map(ds => attribute(~loc=docstring_loc(ds), text_attr(ds)), f_txt)
+ }
+}
+
+module Cl = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ pcl_desc: d,
+ pcl_loc: loc,
+ pcl_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, pcl_attributes: \"@"(d.pcl_attributes, list{a})}
+
+ let constr = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pcl_constr(a, b))
+ let structure = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcl_structure(a))
+ let fun_ = (~loc=?, ~attrs=?, a, b, c, d) => mk(~loc?, ~attrs?, Pcl_fun(a, b, c, d))
+ let apply = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pcl_apply(a, b))
+ let let_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcl_let(a, b, c))
+ let constraint_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pcl_constraint(a, b))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcl_extension(a))
+ let open_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcl_open(a, b, c))
+}
+
+module Cty = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, d) => {
+ pcty_desc: d,
+ pcty_loc: loc,
+ pcty_attributes: attrs,
+ }
+ let attr = (d, a) => {...d, pcty_attributes: \"@"(d.pcty_attributes, list{a})}
+
+ let constr = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pcty_constr(a, b))
+ let signature = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcty_signature(a))
+ let arrow = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcty_arrow(a, b, c))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcty_extension(a))
+ let open_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcty_open(a, b, c))
+}
+
+module Ctf = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, ~docs=empty_docs, d) => {
+ pctf_desc: d,
+ pctf_loc: loc,
+ pctf_attributes: add_docs_attrs(docs, attrs),
+ }
+
+ let inherit_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pctf_inherit(a))
+ let val_ = (~loc=?, ~attrs=?, a, b, c, d) => mk(~loc?, ~attrs?, Pctf_val(a, b, c, d))
+ let method_ = (~loc=?, ~attrs=?, a, b, c, d) => mk(~loc?, ~attrs?, Pctf_method(a, b, c, d))
+ let constraint_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pctf_constraint(a, b))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pctf_extension(a))
+ let attribute = (~loc=?, a) => mk(~loc?, Pctf_attribute(a))
+ let text = txt => {
+ let f_txt = List.filter(ds => docstring_body(ds) != "", txt)
+ List.map(ds => attribute(~loc=docstring_loc(ds), text_attr(ds)), f_txt)
+ }
+
+ let attr = (d, a) => {...d, pctf_attributes: \"@"(d.pctf_attributes, list{a})}
+}
+
+module Cf = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, ~docs=empty_docs, d) => {
+ pcf_desc: d,
+ pcf_loc: loc,
+ pcf_attributes: add_docs_attrs(docs, attrs),
+ }
+
+ let inherit_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcf_inherit(a, b, c))
+ let val_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcf_val(a, b, c))
+ let method_ = (~loc=?, ~attrs=?, a, b, c) => mk(~loc?, ~attrs?, Pcf_method(a, b, c))
+ let constraint_ = (~loc=?, ~attrs=?, a, b) => mk(~loc?, ~attrs?, Pcf_constraint(a, b))
+ let initializer_ = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcf_initializer(a))
+ let extension = (~loc=?, ~attrs=?, a) => mk(~loc?, ~attrs?, Pcf_extension(a))
+ let attribute = (~loc=?, a) => mk(~loc?, Pcf_attribute(a))
+ let text = txt => {
+ let f_txt = List.filter(ds => docstring_body(ds) != "", txt)
+ List.map(ds => attribute(~loc=docstring_loc(ds), text_attr(ds)), f_txt)
+ }
+
+ let virtual_ = ct => Cfk_virtual(ct)
+ let concrete = (o, e) => Cfk_concrete(o, e)
+
+ let attr = (d, a) => {...d, pcf_attributes: \"@"(d.pcf_attributes, list{a})}
+}
+
+module Val = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~prim=list{},
+ name,
+ typ,
+ ) => {
+ pval_name: name,
+ pval_type: typ,
+ pval_attributes: add_docs_attrs(docs, attrs),
+ pval_loc: loc,
+ pval_prim: prim,
+ }
+}
+
+module Md = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ name,
+ typ,
+ ) => {
+ pmd_name: name,
+ pmd_type: typ,
+ pmd_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ pmd_loc: loc,
+ }
+}
+
+module Mtd = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ ~typ=?,
+ name,
+ ) => {
+ pmtd_name: name,
+ pmtd_type: typ,
+ pmtd_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ pmtd_loc: loc,
+ }
+}
+
+module Mb = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ name,
+ expr,
+ ) => {
+ pmb_name: name,
+ pmb_expr: expr,
+ pmb_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ pmb_loc: loc,
+ }
+}
+
+module Opn = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, ~docs=empty_docs, ~override=Fresh, lid) => {
+ popen_lid: lid,
+ popen_override: override,
+ popen_loc: loc,
+ popen_attributes: add_docs_attrs(docs, attrs),
+ }
+}
+
+module Incl = {
+ let mk = (~loc=default_loc.contents, ~attrs=list{}, ~docs=empty_docs, mexpr) => {
+ pincl_mod: mexpr,
+ pincl_loc: loc,
+ pincl_attributes: add_docs_attrs(docs, attrs),
+ }
+}
+
+module Vb = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ pat,
+ expr,
+ ) => {
+ pvb_pat: pat,
+ pvb_expr: expr,
+ pvb_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ pvb_loc: loc,
+ }
+}
+
+module Ci = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ ~virt=Concrete,
+ ~params=list{},
+ name,
+ expr,
+ ) => {
+ pci_virt: virt,
+ pci_params: params,
+ pci_name: name,
+ pci_expr: expr,
+ pci_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ pci_loc: loc,
+ }
+}
+
+module Type = {
+ let mk = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~text=list{},
+ ~params=list{},
+ ~cstrs=list{},
+ ~kind=Ptype_abstract,
+ ~priv=Public,
+ ~manifest=?,
+ name,
+ ) => {
+ ptype_name: name,
+ ptype_params: params,
+ ptype_cstrs: cstrs,
+ ptype_kind: kind,
+ ptype_private: priv,
+ ptype_manifest: manifest,
+ ptype_attributes: add_text_attrs(text, add_docs_attrs(docs, attrs)),
+ ptype_loc: loc,
+ }
+
+ let constructor = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~info=empty_info,
+ ~args=Pcstr_tuple(list{}),
+ ~res=?,
+ name,
+ ) => {
+ pcd_name: name,
+ pcd_args: args,
+ pcd_res: res,
+ pcd_loc: loc,
+ pcd_attributes: add_info_attrs(info, attrs),
+ }
+
+ let field = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~info=empty_info,
+ ~mut=Immutable,
+ name,
+ typ,
+ ) => {
+ pld_name: name,
+ pld_mutable: mut,
+ pld_type: typ,
+ pld_loc: loc,
+ pld_attributes: add_info_attrs(info, attrs),
+ }
+}
+
+@ocaml.doc(" Type extensions ")
+module Te = {
+ let mk = (~attrs=list{}, ~docs=empty_docs, ~params=list{}, ~priv=Public, path, constructors) => {
+ ptyext_path: path,
+ ptyext_params: params,
+ ptyext_constructors: constructors,
+ ptyext_private: priv,
+ ptyext_attributes: add_docs_attrs(docs, attrs),
+ }
+
+ let constructor = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~info=empty_info,
+ name,
+ kind,
+ ) => {
+ pext_name: name,
+ pext_kind: kind,
+ pext_loc: loc,
+ pext_attributes: add_docs_attrs(docs, add_info_attrs(info, attrs)),
+ }
+
+ let decl = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~info=empty_info,
+ ~args=Pcstr_tuple(list{}),
+ ~res=?,
+ name,
+ ) => {
+ pext_name: name,
+ pext_kind: Pext_decl(args, res),
+ pext_loc: loc,
+ pext_attributes: add_docs_attrs(docs, add_info_attrs(info, attrs)),
+ }
+
+ let rebind = (
+ ~loc=default_loc.contents,
+ ~attrs=list{},
+ ~docs=empty_docs,
+ ~info=empty_info,
+ name,
+ lid,
+ ) => {
+ pext_name: name,
+ pext_kind: Pext_rebind(lid),
+ pext_loc: loc,
+ pext_attributes: add_docs_attrs(docs, add_info_attrs(info, attrs)),
+ }
+}
+
+module Csig = {
+ let mk = (self, fields) => {
+ pcsig_self: self,
+ pcsig_fields: fields,
+ }
+}
+
+module Cstr = {
+ let mk = (self, fields) => {
+ pcstr_self: self,
+ pcstr_fields: fields,
+ }
+}
diff --git a/analysis/examples/larger-project/src/asttypes.js b/analysis/examples/larger-project/src/asttypes.js
new file mode 100644
index 000000000..d856702bf
--- /dev/null
+++ b/analysis/examples/larger-project/src/asttypes.js
@@ -0,0 +1,2 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
diff --git a/analysis/examples/larger-project/src/asttypes.res b/analysis/examples/larger-project/src/asttypes.res
new file mode 100644
index 000000000..d35684252
--- /dev/null
+++ b/analysis/examples/larger-project/src/asttypes.res
@@ -0,0 +1,60 @@
+@@ocaml.text(
+ /* ************************************************************************ */
+ /* */
+ /* OCaml */
+ /* */
+ /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
+ /* */
+ /* Copyright 1996 Institut National de Recherche en Informatique et */
+ /* en Automatique. */
+ /* */
+ /* All rights reserved. This file is distributed under the terms of */
+ /* the GNU Lesser General Public License version 2.1, with the */
+ /* special exception on linking described in the file LICENSE. */
+ /* */
+ /* ************************************************************************ */
+
+ " Auxiliary AST types used by parsetree and typedtree. "
+)
+
+type constant =
+ | Const_int(int)
+ | Const_char(char)
+ | Const_string(string, option)
+ | Const_float(string)
+ | Const_int32(int32)
+ | Const_int64(int64)
+ | Const_nativeint(nativeint)
+
+type rec_flag = Nonrecursive | Recursive
+
+type direction_flag = Upto | Downto
+
+/* Order matters, used in polymorphic comparison */
+type private_flag = Private | Public
+
+type mutable_flag = Immutable | Mutable
+
+type virtual_flag = Virtual | Concrete
+
+type override_flag = Override | Fresh
+
+type closed_flag = Closed | Open
+
+type label = string
+
+type arg_label =
+ | Nolabel
+ | Labelled(string) /* label:T -> ... */
+ | Optional(string) /* ?label:T -> ... */
+
+type loc<'a> = Location.loc<'a> = {
+ txt: 'a,
+ loc: Location.t,
+}
+
+type variance =
+ | Covariant
+ | Contravariant
+ | Invariant
+
diff --git a/analysis/examples/larger-project/src/clflags.js b/analysis/examples/larger-project/src/clflags.js
new file mode 100644
index 000000000..500437dc5
--- /dev/null
+++ b/analysis/examples/larger-project/src/clflags.js
@@ -0,0 +1,932 @@
+// Generated by ReScript, PLEASE EDIT WITH CARE
+
+import * as Arg from "rescript/lib/es6/arg.js";
+import * as Sys from "rescript/lib/es6/sys.js";
+import * as List from "rescript/lib/es6/list.js";
+import * as Misc from "./misc.js";
+import * as Curry from "rescript/lib/es6/curry.js";
+import * as Config from "./config.js";
+import * as Printf from "rescript/lib/es6/printf.js";
+import * as Filename from "rescript/lib/es6/filename.js";
+import * as Pervasives from "rescript/lib/es6/pervasives.js";
+import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
+
+var Int_arg_helper = {};
+
+var Float_arg_helper = {};
+
+var objfiles = {
+ contents: /* [] */0
+};
+
+var ccobjs = {
+ contents: /* [] */0
+};
+
+var dllibs = {
+ contents: /* [] */0
+};
+
+var compile_only = {
+ contents: false
+};
+
+var output_name = {
+ contents: undefined
+};
+
+var include_dirs = {
+ contents: /* [] */0
+};
+
+var no_std_include = {
+ contents: false
+};
+
+var print_types = {
+ contents: false
+};
+
+var make_archive = {
+ contents: false
+};
+
+var debug = {
+ contents: false
+};
+
+var fast = {
+ contents: false
+};
+
+var use_linscan = {
+ contents: false
+};
+
+var link_everything = {
+ contents: false
+};
+
+var custom_runtime = {
+ contents: false
+};
+
+var no_check_prims = {
+ contents: false
+};
+
+var bytecode_compatible_32 = {
+ contents: false
+};
+
+var output_c_object = {
+ contents: false
+};
+
+var output_complete_object = {
+ contents: false
+};
+
+var all_ccopts = {
+ contents: /* [] */0
+};
+
+var classic = {
+ contents: false
+};
+
+var nopervasives = {
+ contents: false
+};
+
+var preprocessor = {
+ contents: undefined
+};
+
+var all_ppx = {
+ contents: /* [] */0
+};
+
+var annotations = {
+ contents: false
+};
+
+var binary_annotations = {
+ contents: false
+};
+
+var use_threads = {
+ contents: false
+};
+
+var use_vmthreads = {
+ contents: false
+};
+
+var noassert = {
+ contents: false
+};
+
+var verbose = {
+ contents: false
+};
+
+var noversion = {
+ contents: false
+};
+
+var noprompt = {
+ contents: false
+};
+
+var nopromptcont = {
+ contents: false
+};
+
+var init_file = {
+ contents: undefined
+};
+
+var noinit = {
+ contents: false
+};
+
+var open_modules = {
+ contents: /* [] */0
+};
+
+var use_prims = {
+ contents: ""
+};
+
+var use_runtime = {
+ contents: ""
+};
+
+var principal = {
+ contents: false
+};
+
+var real_paths = {
+ contents: true
+};
+
+var recursive_types = {
+ contents: false
+};
+
+var strict_sequence = {
+ contents: false
+};
+
+var strict_formats = {
+ contents: false
+};
+
+var applicative_functors = {
+ contents: true
+};
+
+var make_runtime = {
+ contents: false
+};
+
+var gprofile = {
+ contents: false
+};
+
+var c_compiler = {
+ contents: undefined
+};
+
+var no_auto_link = {
+ contents: false
+};
+
+var dllpaths = {
+ contents: /* [] */0
+};
+
+var make_package = {
+ contents: false
+};
+
+var for_package = {
+ contents: undefined
+};
+
+var error_size = {
+ contents: 500
+};
+
+var float_const_prop = {
+ contents: true
+};
+
+var transparent_modules = {
+ contents: false
+};
+
+var dump_source = {
+ contents: false
+};
+
+var dump_parsetree = {
+ contents: false
+};
+
+var dump_typedtree = {
+ contents: false
+};
+
+var dump_rawlambda = {
+ contents: false
+};
+
+var dump_lambda = {
+ contents: false
+};
+
+var dump_rawclambda = {
+ contents: false
+};
+
+var dump_clambda = {
+ contents: false
+};
+
+var dump_rawflambda = {
+ contents: false
+};
+
+var dump_flambda = {
+ contents: false
+};
+
+var dump_flambda_let = {
+ contents: undefined
+};
+
+var dump_flambda_verbose = {
+ contents: false
+};
+
+var dump_instr = {
+ contents: false
+};
+
+var keep_asm_file = {
+ contents: false
+};
+
+var optimize_for_speed = {
+ contents: true
+};
+
+var opaque = {
+ contents: false
+};
+
+var dump_cmm = {
+ contents: false
+};
+
+var dump_selection = {
+ contents: false
+};
+
+var dump_cse = {
+ contents: false
+};
+
+var dump_live = {
+ contents: false
+};
+
+var dump_avail = {
+ contents: false
+};
+
+var dump_spill = {
+ contents: false
+};
+
+var dump_split = {
+ contents: false
+};
+
+var dump_interf = {
+ contents: false
+};
+
+var dump_prefer = {
+ contents: false
+};
+
+var dump_regalloc = {
+ contents: false
+};
+
+var dump_reload = {
+ contents: false
+};
+
+var dump_scheduling = {
+ contents: false
+};
+
+var dump_linear = {
+ contents: false
+};
+
+var dump_interval = {
+ contents: false
+};
+
+var keep_startup_file = {
+ contents: false
+};
+
+var dump_combine = {
+ contents: false
+};
+
+var debug_runavail = {
+ contents: false
+};
+
+var native_code = {
+ contents: false
+};
+
+var force_slash = {
+ contents: false
+};
+
+var clambda_checks = {
+ contents: false
+};
+
+var flambda_invariant_checks = {
+ contents: true
+};
+
+var dont_write_files = {
+ contents: false
+};
+
+function std_include_flag(prefix) {
+ if (no_std_include.contents) {
+ return "";
+ } else {
+ return prefix + Curry._1(Filename.quote, Config.standard_library);
+ }
+}
+
+function std_include_dir(param) {
+ if (no_std_include.contents) {
+ return /* [] */0;
+ } else {
+ return {
+ hd: Config.standard_library,
+ tl: /* [] */0
+ };
+ }
+}
+
+var shared = {
+ contents: false
+};
+
+var dlcode = {
+ contents: true
+};
+
+var tmp = Config.architecture === "amd64" ? true : false;
+
+var pic_code = {
+ contents: tmp
+};
+
+var runtime_variant = {
+ contents: ""
+};
+
+var keep_docs = {
+ contents: false
+};
+
+var keep_locs = {
+ contents: true
+};
+
+var unsafe_string = {
+ contents: false
+};
+
+var classic_inlining = {
+ contents: false
+};
+
+var inlining_report = {
+ contents: false
+};
+
+var afl_instrument = {
+ contents: false
+};
+
+var afl_inst_ratio = {
+ contents: 100
+};
+
+var simplify_rounds = {
+ contents: undefined
+};
+
+var default_simplify_rounds = {
+ contents: 1
+};
+
+function rounds(param) {
+ var r = simplify_rounds.contents;
+ if (r !== undefined) {
+ return r;
+ } else {
+ return default_simplify_rounds.contents;
+ }
+}
+
+var default_inline_threshold = 10 / 8;
+
+var default_inline_toplevel_threshold = 16 * default_inline_threshold | 0;
+
+var unbox_specialised_args = {
+ contents: true
+};
+
+var unbox_free_vars_of_closures = {
+ contents: true
+};
+
+var unbox_closures = {
+ contents: false
+};
+
+var unbox_closures_factor = {
+ contents: 10
+};
+
+var remove_unused_arguments = {
+ contents: false
+};
+
+var classic_arguments_inline_threshold = 10 / 8;
+
+var classic_arguments_inline_toplevel_threshold = 1;
+
+var classic_arguments = {
+ inline_call_cost: undefined,
+ inline_alloc_cost: undefined,
+ inline_prim_cost: undefined,
+ inline_branch_cost: undefined,
+ inline_indirect_cost: undefined,
+ inline_lifting_benefit: undefined,
+ inline_branch_factor: undefined,
+ inline_max_depth: undefined,
+ inline_max_unroll: undefined,
+ inline_threshold: classic_arguments_inline_threshold,
+ inline_toplevel_threshold: classic_arguments_inline_toplevel_threshold
+};
+
+var o2_arguments_inline_call_cost = 10;
+
+var o2_arguments_inline_alloc_cost = 14;
+
+var o2_arguments_inline_prim_cost = 6;
+
+var o2_arguments_inline_branch_cost = 10;
+
+var o2_arguments_inline_indirect_cost = 8;
+
+var o2_arguments_inline_max_depth = 2;
+
+var o2_arguments_inline_threshold = 25;
+
+var o2_arguments_inline_toplevel_threshold = 400;
+
+var o2_arguments = {
+ inline_call_cost: o2_arguments_inline_call_cost,
+ inline_alloc_cost: o2_arguments_inline_alloc_cost,
+ inline_prim_cost: o2_arguments_inline_prim_cost,
+ inline_branch_cost: o2_arguments_inline_branch_cost,
+ inline_indirect_cost: o2_arguments_inline_indirect_cost,
+ inline_lifting_benefit: undefined,
+ inline_branch_factor: undefined,
+ inline_max_depth: o2_arguments_inline_max_depth,
+ inline_max_unroll: undefined,
+ inline_threshold: o2_arguments_inline_threshold,
+ inline_toplevel_threshold: o2_arguments_inline_toplevel_threshold
+};
+
+var o3_arguments_inline_call_cost = 15;
+
+var o3_arguments_inline_alloc_cost = 21;
+
+var o3_arguments_inline_prim_cost = 9;
+
+var o3_arguments_inline_branch_cost = 15;
+
+var o3_arguments_inline_indirect_cost = 12;
+
+var o3_arguments_inline_branch_factor = 0;
+
+var o3_arguments_inline_max_depth = 3;
+
+var o3_arguments_inline_max_unroll = 1;
+
+var o3_arguments_inline_threshold = 50;
+
+var o3_arguments_inline_toplevel_threshold = 800;
+
+var o3_arguments = {
+ inline_call_cost: o3_arguments_inline_call_cost,
+ inline_alloc_cost: o3_arguments_inline_alloc_cost,
+ inline_prim_cost: o3_arguments_inline_prim_cost,
+ inline_branch_cost: o3_arguments_inline_branch_cost,
+ inline_indirect_cost: o3_arguments_inline_indirect_cost,
+ inline_lifting_benefit: undefined,
+ inline_branch_factor: o3_arguments_inline_branch_factor,
+ inline_max_depth: o3_arguments_inline_max_depth,
+ inline_max_unroll: o3_arguments_inline_max_unroll,
+ inline_threshold: o3_arguments_inline_threshold,
+ inline_toplevel_threshold: o3_arguments_inline_toplevel_threshold
+};
+
+var all_passes = {
+ contents: /* [] */0
+};
+
+var dumped_passes_list = {
+ contents: /* [] */0
+};
+
+function dumped_pass(s) {
+ if (!List.mem(s, all_passes.contents)) {
+ throw {
+ RE_EXN_ID: "Assert_failure",
+ _1: [
+ "clflags.res",
+ 276,
+ 2
+ ],
+ Error: new Error()
+ };
+ }
+ return List.mem(s, dumped_passes_list.contents);
+}
+
+function set_dumped_pass(s, enabled) {
+ if (!List.mem(s, all_passes.contents)) {
+ return ;
+ }
+ var passes_without_s = List.filter(function (param) {
+ return s !== param;
+ })(dumped_passes_list.contents);
+ var dumped_passes = enabled ? ({
+ hd: s,
+ tl: passes_without_s
+ }) : passes_without_s;
+ dumped_passes_list.contents = dumped_passes;
+
+}
+
+function parse_color_setting(x) {
+ switch (x) {
+ case "always" :
+ return /* Always */1;
+ case "auto" :
+ return /* Auto */0;
+ case "never" :
+ return /* Never */2;
+ default:
+ return ;
+ }
+}
+
+var color = {
+ contents: undefined
+};
+
+var unboxed_types = {
+ contents: false
+};
+
+var arg_spec = {
+ contents: /* [] */0
+};
+
+var arg_names = {
+ contents: Misc.StringMap.empty
+};
+
+function reset_arguments(param) {
+ arg_spec.contents = /* [] */0;
+ arg_names.contents = Misc.StringMap.empty;
+
+}
+
+function add_arguments(loc, args) {
+ return List.iter((function (x) {
+ var arg_name = x[0];
+ try {
+ var loc2 = Curry._2(Misc.StringMap.find, arg_name, arg_names.contents);
+ Curry._1(Printf.eprintf(/* Format */{
+ _0: {
+ TAG: /* String_literal */11,
+ _0: "Warning: plugin argument ",
+ _1: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: {
+ TAG: /* String_literal */11,
+ _0: " is already defined:\n",
+ _1: /* End_of_format */0
+ }
+ }
+ },
+ _1: "Warning: plugin argument %s is already defined:\n"
+ }), arg_name);
+ Curry._1(Printf.eprintf(/* Format */{
+ _0: {
+ TAG: /* String_literal */11,
+ _0: " First definition: ",
+ _1: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: {
+ TAG: /* Char_literal */12,
+ _0: /* '\n' */10,
+ _1: /* End_of_format */0
+ }
+ }
+ },
+ _1: " First definition: %s\n"
+ }), loc2);
+ return Curry._1(Printf.eprintf(/* Format */{
+ _0: {
+ TAG: /* String_literal */11,
+ _0: " New definition: ",
+ _1: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: {
+ TAG: /* Char_literal */12,
+ _0: /* '\n' */10,
+ _1: /* End_of_format */0
+ }
+ }
+ },
+ _1: " New definition: %s\n"
+ }), loc);
+ }
+ catch (raw_exn){
+ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
+ if (exn.RE_EXN_ID === "Not_found") {
+ arg_spec.contents = Pervasives.$at(arg_spec.contents, {
+ hd: x,
+ tl: /* [] */0
+ });
+ arg_names.contents = Curry._3(Misc.StringMap.add, arg_name, loc, arg_names.contents);
+ return ;
+ }
+ throw exn;
+ }
+ }), args);
+}
+
+function print_arguments(usage) {
+ return Arg.usage(arg_spec.contents, usage);
+}
+
+function parse_arguments(f, msg) {
+ try {
+ var argv = {
+ contents: Sys.argv
+ };
+ var current = {
+ contents: Arg.current.contents
+ };
+ return Arg.parse_and_expand_argv_dynamic(current, argv, arg_spec, f, msg);
+ }
+ catch (raw_msg){
+ var msg$1 = Caml_js_exceptions.internalToOCamlException(raw_msg);
+ if (msg$1.RE_EXN_ID === Arg.Bad) {
+ Curry._1(Printf.eprintf(/* Format */{
+ _0: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: /* End_of_format */0
+ },
+ _1: "%s"
+ }), msg$1._1);
+ return Pervasives.exit(2);
+ }
+ if (msg$1.RE_EXN_ID === Arg.Help) {
+ Curry._1(Printf.printf(/* Format */{
+ _0: {
+ TAG: /* String */2,
+ _0: /* No_padding */0,
+ _1: /* End_of_format */0
+ },
+ _1: "%s"
+ }), msg$1._1);
+ return Pervasives.exit(0);
+ }
+ throw msg$1;
+ }
+}
+
+var inline_toplevel_multiplier = 16;
+
+var default_inline_call_cost = 5;
+
+var default_inline_alloc_cost = 7;
+
+var default_inline_prim_cost = 3;
+
+var default_inline_branch_cost = 5;
+
+var default_inline_indirect_cost = 4;
+
+var default_inline_branch_factor = 0.1;
+
+var default_inline_lifting_benefit = 1300;
+
+var default_inline_max_unroll = 0;
+
+var default_inline_max_depth = 1;
+
+var default_unbox_closures_factor = 10;
+
+var o1_arguments = {
+ inline_call_cost: undefined,
+ inline_alloc_cost: undefined,
+ inline_prim_cost: undefined,
+ inline_branch_cost: undefined,
+ inline_indirect_cost: undefined,
+ inline_lifting_benefit: undefined,
+ inline_branch_factor: undefined,
+ inline_max_depth: undefined,
+ inline_max_unroll: undefined,
+ inline_threshold: undefined,
+ inline_toplevel_threshold: undefined
+};
+
+export {
+ Int_arg_helper ,
+ Float_arg_helper ,
+ objfiles ,
+ ccobjs ,
+ dllibs ,
+ compile_only ,
+ output_name ,
+ include_dirs ,
+ no_std_include ,
+ print_types ,
+ make_archive ,
+ debug ,
+ fast ,
+ use_linscan ,
+ link_everything ,
+ custom_runtime ,
+ no_check_prims ,
+ bytecode_compatible_32 ,
+ output_c_object ,
+ output_complete_object ,
+ all_ccopts ,
+ classic ,
+ nopervasives ,
+ preprocessor ,
+ all_ppx ,
+ annotations ,
+ binary_annotations ,
+ use_threads ,
+ use_vmthreads ,
+ noassert ,
+ verbose ,
+ noversion ,
+ noprompt ,
+ nopromptcont ,
+ init_file ,
+ noinit ,
+ open_modules ,
+ use_prims ,
+ use_runtime ,
+ principal ,
+ real_paths ,
+ recursive_types ,
+ strict_sequence ,
+ strict_formats ,
+ applicative_functors ,
+ make_runtime ,
+ gprofile ,
+ c_compiler ,
+ no_auto_link ,
+ dllpaths ,
+ make_package ,
+ for_package ,
+ error_size ,
+ float_const_prop ,
+ transparent_modules ,
+ dump_source ,
+ dump_parsetree ,
+ dump_typedtree ,
+ dump_rawlambda ,
+ dump_lambda ,
+ dump_rawclambda ,
+ dump_clambda ,
+ dump_rawflambda ,
+ dump_flambda ,
+ dump_flambda_let ,
+ dump_flambda_verbose ,
+ dump_instr ,
+ keep_asm_file ,
+ optimize_for_speed ,
+ opaque ,
+ dump_cmm ,
+ dump_selection ,
+ dump_cse ,
+ dump_live ,
+ dump_avail ,
+ dump_spill ,
+ dump_split ,
+ dump_interf ,
+ dump_prefer ,
+ dump_regalloc ,
+ dump_reload ,
+ dump_scheduling ,
+ dump_linear ,
+ dump_interval ,
+ keep_startup_file ,
+ dump_combine ,
+ debug_runavail ,
+ native_code ,
+ force_slash ,
+ clambda_checks ,
+ flambda_invariant_checks ,
+ dont_write_files ,
+ std_include_flag ,
+ std_include_dir ,
+ shared ,
+ dlcode ,
+ pic_code ,
+ runtime_variant ,
+ keep_docs ,
+ keep_locs ,
+ unsafe_string ,
+ classic_inlining ,
+ inlining_report ,
+ afl_instrument ,
+ afl_inst_ratio ,
+ simplify_rounds ,
+ default_simplify_rounds ,
+ rounds ,
+ default_inline_threshold ,
+ inline_toplevel_multiplier ,
+ default_inline_toplevel_threshold ,
+ default_inline_call_cost ,
+ default_inline_alloc_cost ,
+ default_inline_prim_cost ,
+ default_inline_branch_cost ,
+ default_inline_indirect_cost ,
+ default_inline_branch_factor ,
+ default_inline_lifting_benefit ,
+ default_inline_max_unroll ,
+ default_inline_max_depth ,
+ unbox_specialised_args ,
+ unbox_free_vars_of_closures ,
+ unbox_closures ,
+ default_unbox_closures_factor ,
+ unbox_closures_factor ,
+ remove_unused_arguments ,
+ o1_arguments ,
+ classic_arguments ,
+ o2_arguments ,
+ o3_arguments ,
+ all_passes ,
+ dumped_passes_list ,
+ dumped_pass ,
+ set_dumped_pass ,
+ parse_color_setting ,
+ color ,
+ unboxed_types ,
+ arg_spec ,
+ arg_names ,
+ reset_arguments ,
+ add_arguments ,
+ print_arguments ,
+ parse_arguments ,
+
+}
+/* pic_code Not a pure module */
diff --git a/analysis/examples/larger-project/src/clflags.res b/analysis/examples/larger-project/src/clflags.res
new file mode 100644
index 000000000..2ff6bc834
--- /dev/null
+++ b/analysis/examples/larger-project/src/clflags.res
@@ -0,0 +1,346 @@
+/* ************************************************************************ */
+/* */
+/* OCaml */
+/* */
+/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
+/* */
+/* Copyright 1996 Institut National de Recherche en Informatique et */
+/* en Automatique. */
+/* */
+/* All rights reserved. This file is distributed under the terms of */
+/* the GNU Lesser General Public License version 2.1, with the */
+/* special exception on linking described in the file LICENSE. */
+/* */
+/* ************************************************************************ */
+
+/* Command-line parameters */
+
+module Int_arg_helper = {}
+module Float_arg_helper = {
+
+}
+
+let objfiles = ref((list{}: list)) /* .cmo and .cma files */
+and ccobjs = ref((list{}: list)) /* .o, .a, .so and -cclib -lxxx */
+and dllibs = ref((list{}: list)) /* .so and -dllib -lxxx */
+
+let compile_only = ref(false) /* -c */
+and output_name = ref((None: option)) /* -o */
+and include_dirs = ref((list{}: list)) /* -I */
+and no_std_include = ref(false) /* -nostdlib */
+and print_types = ref(false) /* -i */
+and make_archive = ref(false) /* -a */
+and debug = ref(false) /* -g */
+and fast = ref(false) /* -unsafe */
+and use_linscan = ref(false) /* -linscan */
+and link_everything = ref(false) /* -linkall */
+and custom_runtime = ref(false) /* -custom */
+and no_check_prims = ref(false) /* -no-check-prims */
+and bytecode_compatible_32 = ref(false) /* -compat-32 */
+and output_c_object = ref(false) /* -output-obj */
+and output_complete_object = ref(false) /* -output-complete-obj */
+and all_ccopts = ref((list{}: list)) /* -ccopt */
+and classic = ref(false) /* -nolabels */
+and nopervasives = ref(false) /* -nopervasives */
+and preprocessor = ref((None: option)) /* -pp */
+and all_ppx = ref((list{}: list)) /* -ppx */
+let annotations = ref(false) /* -annot */
+let binary_annotations = ref(false) /* -annot */
+and use_threads = ref(false) /* -thread */
+and use_vmthreads = ref(false) /* -vmthread */
+and noassert = ref(false) /* -noassert */
+and verbose = ref(false) /* -verbose */
+and noversion = ref(false) /* -no-version */
+and noprompt = ref(false) /* -noprompt */
+and nopromptcont = ref(false) /* -nopromptcont */
+and init_file = ref((None: option)) /* -init */
+and noinit = ref(false) /* -noinit */
+and open_modules: ref
> = ref(list{}) /* -open */
+and use_prims = ref("") /* -use-prims ... */
+and use_runtime = ref("") /* -use-runtime ... */
+and principal = ref(false) /* -principal */
+and real_paths = ref(true) /* -short-paths */
+and recursive_types = ref(false) /* -rectypes */
+and strict_sequence = ref(false) /* -strict-sequence */
+and strict_formats = ref(false) /* -strict-formats */
+and applicative_functors = ref(true) /* -no-app-funct */
+and make_runtime = ref(false) /* -make-runtime */
+and gprofile = ref(false) /* -p */
+and c_compiler = ref((None: option)) /* -cc */
+and no_auto_link = ref(false) /* -noautolink */
+and dllpaths = ref((list{}: list)) /* -dllpath */
+and make_package = ref(false) /* -pack */
+and for_package = ref((None: option)) /* -for-pack */
+and error_size = ref(500) /* -error-size */
+and float_const_prop = ref(true) /* -no-float-const-prop */
+and transparent_modules = ref(false) /* -trans-mod */
+let dump_source = ref(false) /* -dsource */
+let dump_parsetree = ref(false) /* -dparsetree */
+and dump_typedtree = ref(false) /* -dtypedtree */
+and dump_rawlambda = ref(false) /* -drawlambda */
+and dump_lambda = ref(false) /* -dlambda */
+and dump_rawclambda = ref(false) /* -drawclambda */
+and dump_clambda = ref(false) /* -dclambda */
+and dump_rawflambda = ref(false) /* -drawflambda */
+and dump_flambda = ref(false) /* -dflambda */
+and dump_flambda_let = ref((None: option)) /* -dflambda-let=... */
+and dump_flambda_verbose = ref(false) /* -dflambda-verbose */
+and dump_instr = ref(false) /* -dinstr */
+
+let keep_asm_file = ref(false) /* -S */
+let optimize_for_speed = ref(true) /* -compact */
+and opaque = ref(false) /* -opaque */
+
+and dump_cmm = ref(false) /* -dcmm */
+let dump_selection = ref(false) /* -dsel */
+let dump_cse = ref(false) /* -dcse */
+let dump_live = ref(false) /* -dlive */
+let dump_avail = ref(false) /* -davail */
+let dump_spill = ref(false) /* -dspill */
+let dump_split = ref(false) /* -dsplit */
+let dump_interf = ref(false) /* -dinterf */
+let dump_prefer = ref(false) /* -dprefer */
+let dump_regalloc = ref(false) /* -dalloc */
+let dump_reload = ref(false) /* -dreload */
+let dump_scheduling = ref(false) /* -dscheduling */
+let dump_linear = ref(false) /* -dlinear */
+let dump_interval = ref(false) /* -dinterval */
+let keep_startup_file = ref(false) /* -dstartup */
+let dump_combine = ref(false) /* -dcombine */
+
+let debug_runavail = ref(false) /* -drunavail */
+
+let native_code = ref(false) /* set to true under ocamlopt */
+
+let force_slash = ref(false) /* for ocamldep */
+let clambda_checks = ref(false) /* -clambda-checks */
+
+let flambda_invariant_checks = ref(true) /* -flambda-invariants */
+
+let dont_write_files = ref(false) /* set to true under ocamldoc */
+
+let std_include_flag = prefix =>
+ if no_std_include.contents {
+ ""
+ } else {
+ prefix ++ Filename.quote(Config.standard_library)
+ }
+
+let std_include_dir = () =>
+ if no_std_include.contents {
+ list{}
+ } else {
+ list{Config.standard_library}
+ }
+
+let shared = ref(false) /* -shared */
+let dlcode = ref(true) /* not -nodynlink */
+
+let pic_code = ref(
+ switch Config.architecture {
+ /* -fPIC */
+ | "amd64" => true
+ | _ => false
+ },
+)
+
+let runtime_variant = ref("") /* -runtime-variant */
+
+let keep_docs = ref(false) /* -keep-docs */
+let keep_locs = ref(true) /* -keep-locs */
+let unsafe_string = if Config.safe_string {
+ ref(false)
+} else {
+ ref(!Config.default_safe_string)
+}
+/* -safe-string / -unsafe-string */
+
+let classic_inlining = ref(false) /* -Oclassic */
+let inlining_report = ref(false) /* -inlining-report */
+
+let afl_instrument = ref(Config.afl_instrument) /* -afl-instrument */
+let afl_inst_ratio = ref(100) /* -afl-inst-ratio */
+
+let simplify_rounds = ref(None) /* -rounds */
+let default_simplify_rounds = ref(1) /* -rounds */
+let rounds = () =>
+ switch simplify_rounds.contents {
+ | None => default_simplify_rounds.contents
+ | Some(r) => r
+ }
+
+let default_inline_threshold = if Config.flambda {
+ 10.
+} else {
+ 10. /. 8.
+}
+let inline_toplevel_multiplier = 16
+let default_inline_toplevel_threshold = int_of_float(
+ float(inline_toplevel_multiplier) *. default_inline_threshold,
+)
+let default_inline_call_cost = 5
+let default_inline_alloc_cost = 7
+let default_inline_prim_cost = 3
+let default_inline_branch_cost = 5
+let default_inline_indirect_cost = 4
+let default_inline_branch_factor = 0.1
+let default_inline_lifting_benefit = 1300
+let default_inline_max_unroll = 0
+let default_inline_max_depth = 1
+
+let unbox_specialised_args = ref(true) /* -no-unbox-specialised-args */
+let unbox_free_vars_of_closures = ref(true)
+let unbox_closures = ref(false) /* -unbox-closures */
+let default_unbox_closures_factor = 10
+let unbox_closures_factor = ref(default_unbox_closures_factor) /* -unbox-closures-factor */
+let remove_unused_arguments = ref(false) /* -remove-unused-arguments */
+
+type inlining_arguments = {
+ inline_call_cost: option,
+ inline_alloc_cost: option,
+ inline_prim_cost: option,
+ inline_branch_cost: option,
+ inline_indirect_cost: option,
+ inline_lifting_benefit: option,
+ inline_branch_factor: option,
+ inline_max_depth: option,
+ inline_max_unroll: option,
+ inline_threshold: option,
+ inline_toplevel_threshold: option,
+}
+
+/* o1 is the default */
+let o1_arguments = {
+ inline_call_cost: None,
+ inline_alloc_cost: None,
+ inline_prim_cost: None,
+ inline_branch_cost: None,
+ inline_indirect_cost: None,
+ inline_lifting_benefit: None,
+ inline_branch_factor: None,
+ inline_max_depth: None,
+ inline_max_unroll: None,
+ inline_threshold: None,
+ inline_toplevel_threshold: None,
+}
+
+let classic_arguments = {
+ inline_call_cost: None,
+ inline_alloc_cost: None,
+ inline_prim_cost: None,
+ inline_branch_cost: None,
+ inline_indirect_cost: None,
+ inline_lifting_benefit: None,
+ inline_branch_factor: None,
+ inline_max_depth: None,
+ inline_max_unroll: None,
+ /* [inline_threshold] matches the current compiler's default.
+ Note that this particular fraction can be expressed exactly in
+ floating point. */
+ inline_threshold: Some(10. /. 8.),
+ /* [inline_toplevel_threshold] is not used in classic mode. */
+ inline_toplevel_threshold: Some(1),
+}
+
+let o2_arguments = {
+ inline_call_cost: Some(2 * default_inline_call_cost),
+ inline_alloc_cost: Some(2 * default_inline_alloc_cost),
+ inline_prim_cost: Some(2 * default_inline_prim_cost),
+ inline_branch_cost: Some(2 * default_inline_branch_cost),
+ inline_indirect_cost: Some(2 * default_inline_indirect_cost),
+ inline_lifting_benefit: None,
+ inline_branch_factor: None,
+ inline_max_depth: Some(2),
+ inline_max_unroll: None,
+ inline_threshold: Some(25.),
+ inline_toplevel_threshold: Some(25 * inline_toplevel_multiplier),
+}
+
+let o3_arguments = {
+ inline_call_cost: Some(3 * default_inline_call_cost),
+ inline_alloc_cost: Some(3 * default_inline_alloc_cost),
+ inline_prim_cost: Some(3 * default_inline_prim_cost),
+ inline_branch_cost: Some(3 * default_inline_branch_cost),
+ inline_indirect_cost: Some(3 * default_inline_indirect_cost),
+ inline_lifting_benefit: None,
+ inline_branch_factor: Some(0.),
+ inline_max_depth: Some(3),
+ inline_max_unroll: Some(1),
+ inline_threshold: Some(50.),
+ inline_toplevel_threshold: Some(50 * inline_toplevel_multiplier),
+}
+
+let all_passes: ref> = ref(list{})
+let dumped_passes_list = ref(list{})
+let dumped_pass = s => {
+ assert List.mem(s, all_passes.contents)
+ List.mem(s, dumped_passes_list.contents)
+}
+
+let set_dumped_pass = (s, enabled) =>
+ if List.mem(s, all_passes.contents) {
+ let passes_without_s = List.filter(\"<>"(s), dumped_passes_list.contents)
+ let dumped_passes = if enabled {
+ list{s, ...passes_without_s}
+ } else {
+ passes_without_s
+ }
+
+ dumped_passes_list := dumped_passes
+ }
+
+let parse_color_setting = x =>
+ switch x {
+ | "auto" => Some(Misc.Color.Auto)
+ | "always" => Some(Misc.Color.Always)
+ | "never" => Some(Misc.Color.Never)
+ | _ => None
+ }
+let color: ref