From d31334d1d154b395bb65ca598a13e31cd6417eb7 Mon Sep 17 00:00:00 2001 From: IGI-111 Date: Fri, 26 Jul 2024 18:26:03 +0200 Subject: [PATCH 1/2] Add documentation about Undefined Behavior (#6302) ## Description Add a section in the docs to list known UB. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --- docs/book/src/SUMMARY.md | 1 + docs/book/src/reference/undefined_behavior.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 docs/book/src/reference/undefined_behavior.md diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index a1c7f9edd51..b6d2a2f97cd 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -70,6 +70,7 @@ - [Attributes](./reference/attributes.md) - [Style Guide](./reference/style_guide.md) - [Known Issues and Workarounds](./reference/known_issues_and_workarounds.md) + - [Behavior Considered Undefined](./reference/undefined_behavior.md) - [Differences From Solidity](./reference/solidity_differences.md) - [Differences From Rust](./reference/rust_differences.md) - [Contributing To Sway](./reference/contributing_to_sway.md) diff --git a/docs/book/src/reference/undefined_behavior.md b/docs/book/src/reference/undefined_behavior.md new file mode 100644 index 00000000000..07555223aad --- /dev/null +++ b/docs/book/src/reference/undefined_behavior.md @@ -0,0 +1,15 @@ +# Behavior Considered Undefined + +Sway code that contains any of the following behavior is considered undefined. +The compiler is allowed to treat undefined Sway code however it desires, +including removing it or replacing it with any other Sway code. + +This is not an exhaustive list, it may grow or shrink, there is no formal model +of Sway's semantics so there may be more behavior considered undefined. We +reserve the right to make some of the listed behavior defined in the future. + +* Invalid arithmetic operations (overflows, underflows, division by zero, etc) +* Misuse of compiler intrinsics +* Incorrect use of inline assembly +* Reading and writing `raw_ptr` and `raw_slice` +* Slicing and indexing out of bounds by directly using compiler intrinsics. From ec01af49c8ad7dcbc48e1e44e926d15fe4c5d532 Mon Sep 17 00:00:00 2001 From: dima-safin-2025 Date: Fri, 26 Jul 2024 16:26:20 -0300 Subject: [PATCH 2/2] fix: update the document link for Manual Storage Management. (#6301) ## Description related https://github.com/FuelLabs/sway/issues/6300 ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com> --- docs/book/src/reference/known_issues_and_workarounds.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/reference/known_issues_and_workarounds.md b/docs/book/src/reference/known_issues_and_workarounds.md index 50ae1052b67..d60c5d23de3 100644 --- a/docs/book/src/reference/known_issues_and_workarounds.md +++ b/docs/book/src/reference/known_issues_and_workarounds.md @@ -6,7 +6,7 @@ ## Missing Features -* [#1182](https://github.com/FuelLabs/sway/issues/1182) Arrays in a `storage` block are not yet supported. See the [Manual Storage Management](../blockchain-development/storage.md#manual-storage-management) section for details on how to use `store` and `get` from the standard library to manage storage slots directly. Note, however, that `StorageMap` _does_ support arbitrary types for `K` and `V` without any limitations. +* [#1182](https://github.com/FuelLabs/sway/issues/1182) Arrays in a `storage` block are not yet supported. See the [Manual Storage Management](../advanced/advanced_storage.md#manual-storage-management) section for details on how to use `store` and `get` from the standard library to manage storage slots directly. Note, however, that `StorageMap` _does_ support arbitrary types for `K` and `V` without any limitations. ## General