diff --git a/compilers/package-lock.json b/compilers/package-lock.json index 0bead56f6..7b622a747 100644 --- a/compilers/package-lock.json +++ b/compilers/package-lock.json @@ -14,7 +14,7 @@ "rescript-1000": "npm:rescript@10.0.0", "rescript-1010": "npm:rescript@10.1.0", "rescript-1100": "npm:rescript@11.0.0", - "rescript-1110": "npm:rescript@11.1.0-rc.6", + "rescript-1110": "npm:rescript@11.1.0-rc.8", "rescript-820": "npm:bs-platform@8.2.0", "rescript-902": "npm:bs-platform@9.0.2", "rescript-912": "npm:rescript@9.1.2" @@ -136,9 +136,9 @@ }, "node_modules/rescript-1110": { "name": "rescript", - "version": "11.1.0-rc.6", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.6.tgz", - "integrity": "sha512-chaNkU5xvWC+NOKflmNiQDMj8wu1Vk+SX9vUH84m9gT9cGE49ml1rG25XUPlKQ4EJ+AR+0XYLfxxvzjKYC+qvQ==", + "version": "11.1.0-rc.8", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.8.tgz", + "integrity": "sha512-5It7moo2zRvxJARi8SlEQ5YTXqsfpOpaiDsOa/9V8rE+xY3Hxt3Bhd4tAyOzSLJlpBbB+0wc6JmujhZ61eRHZg==", "hasInstallScript": true, "bin": { "bsc": "bsc", @@ -253,9 +253,9 @@ "integrity": "sha512-uIUwDZZmDUb7ymGkBiiGioxMg8hXh1mze/2k/qhYQcZGgi7PrLHQIW9AksM7gb9WnpjCAvFsA8U2VgC0nA468w==" }, "rescript-1110": { - "version": "npm:rescript@11.1.0-rc.6", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.6.tgz", - "integrity": "sha512-chaNkU5xvWC+NOKflmNiQDMj8wu1Vk+SX9vUH84m9gT9cGE49ml1rG25XUPlKQ4EJ+AR+0XYLfxxvzjKYC+qvQ==" + "version": "npm:rescript@11.1.0-rc.8", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.8.tgz", + "integrity": "sha512-5It7moo2zRvxJARi8SlEQ5YTXqsfpOpaiDsOa/9V8rE+xY3Hxt3Bhd4tAyOzSLJlpBbB+0wc6JmujhZ61eRHZg==" }, "rescript-820": { "version": "npm:bs-platform@8.2.0", diff --git a/compilers/package.json b/compilers/package.json index 8d8028eab..d5d5eb35b 100644 --- a/compilers/package.json +++ b/compilers/package.json @@ -10,7 +10,7 @@ "rescript-1000": "npm:rescript@10.0.0", "rescript-1010": "npm:rescript@10.1.0", "rescript-1100": "npm:rescript@11.0.0", - "rescript-1110": "npm:rescript@11.1.0-rc.6", + "rescript-1110": "npm:rescript@11.1.0-rc.8", "rescript-820": "npm:bs-platform@8.2.0", "rescript-902": "npm:bs-platform@9.0.2", "rescript-912": "npm:rescript@9.1.2" diff --git a/misc_docs/syntax/extension_todo.mdx b/misc_docs/syntax/extension_todo.mdx new file mode 100644 index 000000000..dbeb8c706 --- /dev/null +++ b/misc_docs/syntax/extension_todo.mdx @@ -0,0 +1,48 @@ +--- +id: "todo" +keywords: ["todo"] +name: "%todo" +summary: "This is the `todo` extension point." +category: "extensionpoints" +--- + +**Since 11.1** + +`%todo` is used to tell the compiler that some code still needs to be implemented. + + + +```res +let implementMeLater = (): string => %todo("This should return a string eventually.") + +let x = implementMeLater() + +Console.log(x->String.includes("x")) +``` + +```js +var Js_exn = require("./stdlib/js_exn.js"); + +function implementMeLater() { + return Js_exn.raiseError("playground.res:1:37-42 - Todo: This should return a string eventually."); +} + +var x = Js_exn.raiseError("playground.res:1:37-42 - Todo: This should return a string eventually."); + +console.log(x.includes("x")); +``` + + + +It can also be used without a text message: + +```res +let implementMeLater = (): string => %todo +``` + +This will crash when executed. We suggest to [promote the warning to an error](/docs/manual/latest/build-overview#compile-with-stricter-errors-in-ci) when building for production. + +### References + +* [Stricter compilation in CI](/docs/manual/latest/build-overview#compile-with-stricter-errors-in-ci) +* [Extension Point Attributes](/docs/manual/latest/attribute#extension-point) diff --git a/pages/docs/manual/latest/build-overview.mdx b/pages/docs/manual/latest/build-overview.mdx index 10c67d65d..845d34351 100644 --- a/pages/docs/manual/latest/build-overview.mdx +++ b/pages/docs/manual/latest/build-overview.mdx @@ -69,3 +69,15 @@ If you ever get into a stale build for edge-case reasons, use: ```sh rescript clean ``` + +## Compile with stricter errors in CI + +**Since 11.1** + +You may want to compile your project with stricter rules for production, than when developing. With the `-warn-error` build flag, this can easily be done, for instance in a continuous integration script. E.g.: + +```sh +rescript -warn-error +110 +``` + +Here, warning number 110, which is triggered when a [`%todo`](/syntax-lookup#todo) has been found, gets promoted to an error. The full list of warning numbers can be found [here](/docs/manual/latest/warning-numbers). diff --git a/pages/docs/manual/latest/interop-cheatsheet.mdx b/pages/docs/manual/latest/interop-cheatsheet.mdx index ecbe369dd..41c4b195e 100644 --- a/pages/docs/manual/latest/interop-cheatsheet.mdx +++ b/pages/docs/manual/latest/interop-cheatsheet.mdx @@ -51,10 +51,9 @@ This is a glossary with examples. All the features are described by later pages. - [`%debugger`](embed-raw-javascript#debugger) - [`%external`](bind-to-global-js-values#special-global-values) - - - [`%raw`](embed-raw-javascript#paste-raw-js-code) - [`%re`](primitive-types#regular-expression) +- [`%todo`](/syntax-lookup#todo) ## Raw JS diff --git a/src/common/WarningFlagDescription.res b/src/common/WarningFlagDescription.res index e93fa612a..dd818eba5 100644 --- a/src/common/WarningFlagDescription.res +++ b/src/common/WarningFlagDescription.res @@ -70,6 +70,7 @@ let numeric = [ (107, "Integer literal exceeds the range of representable integers of type int"), (108, "Uninterpreted delimiters (for unicode)"), (109, "Toplevel expression has unit type"), + (110, "Todo found"), ] let letterAll = numeric->Belt.Array.map(fst) @@ -226,7 +227,12 @@ module Parser = { | _ => () } - ret + ret->Belt.SortArray.stableSortBy((v1, v2) => { + let a = v1.flag->Belt.Int.fromString + let b = v2.flag->Belt.Int.fromString + + compare(a, b) + }) } let parse = (input: string): result, string> =>