Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions misc_docs/syntax/decorator_dead.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id: "dead-decorator"
keywords: ["dead", "decorator"]
name: "@dead"
summary: "This is the `@dead` decorator."
category: "decorators"
---

> This decorator requires [`reanalyze`](https://github.com/rescript-association/reanalyze), a code analysis tool for ReScript, to be installed. [Click here to read about how you get started with reanalyze.](https://github.com/rescript-association/reanalyze).

`@dead` is picked up by reanalyze's dead code analysis, and suppresses reporting on the value/type, but can also be used to force the analysis to consider a value as dead. Typically used to acknowledge cases of dead code you are not planning to address right now, but can be searched easily later.

### References

- [Reanalyze: Controlling reports with Annotations](https://github.com/rescript-association/reanalyze#dce-controlling-reports-with-annotations)
15 changes: 15 additions & 0 deletions misc_docs/syntax/decorator_does_not_raise.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id: "does-not-raise-decorator"
keywords: ["doesNotRaise", "decorator"]
name: "@doesNotRaise"
summary: "This is the `@doesNotRaise` decorator."
category: "decorators"
---

> This decorator requires [`reanalyze`](https://github.com/rescript-association/reanalyze), a code analysis tool for ReScript, to be installed. [Click here to read about how you get started with reanalyze.](https://github.com/rescript-association/reanalyze).

`@doesNotRaise` is used to override the reanalyze's exception analysis and state that an expression does not raise any exceptions, even though the analysis reports otherwise. This can happen for example in the case of array access where the analysis does not perform range checks but takes a conservative stance that any access could potentially raise.

### References

- [Reanalyze: Exception Analysis](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md)
16 changes: 16 additions & 0 deletions misc_docs/syntax/decorator_live.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: "live-decorator"
keywords: ["live", "decorator"]
name: "@live"
summary: "This is the `@live` decorator."
category: "decorators"
---

> This decorator requires [`reanalyze`](https://github.com/rescript-association/reanalyze), a code analysis tool for ReScript, to be installed. [Click here to read about how you get started with reanalyze.](https://github.com/rescript-association/reanalyze).

`@live` tells reanalyze's dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values.
It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.

### References

- [Reanalyze: Controlling reports with Annotations](https://github.com/rescript-association/reanalyze#dce-controlling-reports-with-annotations)
15 changes: 15 additions & 0 deletions misc_docs/syntax/decorator_raises.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
id: "raises-decorator"
keywords: ["raises", "decorator"]
name: "@raises"
summary: "This is the `@raises` decorator."
category: "decorators"
---

> This decorator requires [`reanalyze`](https://github.com/rescript-association/reanalyze), a code analysis tool for ReScript, to be installed. [Click here to read about how you get started with reanalyze.](https://github.com/rescript-association/reanalyze).

`@raises` is picked up by reanalyze's exception analysis, and acknowledges that a function can raise exceptions that are not caught, and suppresses a warning in that case. Callers of the functions are then subjected to the same rule. Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions.

### References

- [Reanalyze: Exception Analysis](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md)