repo
stringlengths
5
53
pr_number
int32
1
321k
task_type
stringclasses
2 values
issue_text
stringlengths
0
81.2k
pr_title
stringlengths
1
319
pr_body
stringlengths
0
105k
base_sha
stringlengths
40
40
head_sha
stringlengths
40
40
gold_diff
stringlengths
0
202M
changed_files
listlengths
0
100
review_threads
listlengths
0
100
test_patch
stringlengths
0
23.4M
merged
bool
1 class
FuelLabs/fuels-ts
3,875
issue_to_patch
Allow Custom Modifications On Transaction Request When Using `InvocationScope` During the implementation of [assembleTx](https://github.com/FuelLabs/fuels-ts/pull/3747), we had to roll back the changes introduced in [#3773](https://github.com/FuelLabs/fuels-ts/pull/3773). The reverted changes allowed users to manuall...
feat: support TX customization at BaseInvocationScope
- Closes #3815 - Closes #3890 # Release notes In this release, we: - Added support for on-the-fly modifications to `TransactionRequest` when using `InvocationScope` - Made `provider.assembleTx()` to consider `reserveGas` when setting TX `gasLimit` # Summary The method `fromRequest` can be used to set...
4cbd72c1373e2cf2eb29288c65b56bf4e35a045e
28af88a4cdf73a75d35c04e9ac26888b59eb4d79
diff --git a/.changeset/huge-stars-attend.md b/.changeset/huge-stars-attend.md new file mode 100644 index 00000000000..d07df14fb0d --- /dev/null +++ b/.changeset/huge-stars-attend.md @@ -0,0 +1,6 @@ +--- +"@fuel-ts/account": patch +"@fuel-ts/program": patch +--- + +feat: support TX customization at BaseInvocationScope ...
[ ".changeset/huge-stars-attend.md", "apps/docs/.vitepress/config.ts", "apps/docs/src/guide/contracts/call-parameters.md", "apps/docs/src/guide/contracts/cost-estimation.md", "apps/docs/src/guide/contracts/custom-contract-calls.md", "apps/docs/src/guide/contracts/snippets/call-parameters/forward.ts", "app...
[ { "comment": "```suggestion\r\nFor instance, imagine a liquidity pool contract where users can deposit a specific asset to receive some form of benefit. To enhance the experience and make it more attractive, one could use a predicate to cover the transaction fees. This way, users only need to provide the asset ...
diff --git a/packages/fuel-gauge/src/assemble-tx.test.ts b/packages/fuel-gauge/src/assemble-tx.test.ts index 49ca9084b97..6f2597dad38 100644 --- a/packages/fuel-gauge/src/assemble-tx.test.ts +++ b/packages/fuel-gauge/src/assemble-tx.test.ts @@ -12,9 +12,13 @@ import { ErrorCode, FuelError, } from 'fuels'; +impor...
true
FuelLabs/fuels-ts
3,875
comment_to_fix
feat: support TX customization at BaseInvocationScope
```suggestion For instance, imagine a liquidity pool contract where users can deposit a specific asset to receive some form of benefit. To enhance the experience and make it more attractive, one could use a predicate to cover the transaction fees. This way, users only need to provide the asset they wish to deposit wit...
4cbd72c1373e2cf2eb29288c65b56bf4e35a045e
28af88a4cdf73a75d35c04e9ac26888b59eb4d79
diff --git a/apps/docs/src/guide/contracts/custom-contract-calls.md b/apps/docs/src/guide/contracts/custom-contract-calls.md new file mode 100644 index 00000000000..97757c869f2 --- /dev/null +++ b/apps/docs/src/guide/contracts/custom-contract-calls.md @@ -0,0 +1,29 @@ +# Custom Contract Call + +In certain scenarios, yo...
[ "apps/docs/src/guide/contracts/custom-contract-calls.md" ]
[ { "comment": "```suggestion\r\nFor instance, imagine a liquidity pool contract where users can deposit a specific asset to receive some form of benefit. To enhance the experience and make it more attractive, one could use a predicate to cover the transaction fees. This way, users only need to provide the asset ...
true
FuelLabs/fuels-ts
3,875
comment_to_fix
feat: support TX customization at BaseInvocationScope
```suggestion It tells the SDK to skip the automatic `assembleTx` step during the `.call()` execution, since we’ve already manually assembled and funded the transaction using `provider.assembleTx()`. ```
4cbd72c1373e2cf2eb29288c65b56bf4e35a045e
28af88a4cdf73a75d35c04e9ac26888b59eb4d79
diff --git a/apps/docs/src/guide/contracts/custom-contract-calls.md b/apps/docs/src/guide/contracts/custom-contract-calls.md new file mode 100644 index 00000000000..97757c869f2 --- /dev/null +++ b/apps/docs/src/guide/contracts/custom-contract-calls.md @@ -0,0 +1,29 @@ +# Custom Contract Call + +In certain scenarios, yo...
[ "apps/docs/src/guide/contracts/custom-contract-calls.md" ]
[ { "comment": "```suggestion\r\nIt tells the SDK to skip the automatic `assembleTx` step during the `.call()` execution, since we’ve already manually assembled and funded the transaction using `provider.assembleTx()`.\r\n```", "path": "apps/docs/src/guide/contracts/custom-contract-calls.md", "hunk": "@@ ...
true
FuelLabs/fuels-ts
3,875
comment_to_fix
feat: support TX customization at BaseInvocationScope
```suggestion Skipping this step prevents the SDK from overwriting the prepared transaction and ensures the custom logic remains intact, such as using a predicate as the fee payer. ```
4cbd72c1373e2cf2eb29288c65b56bf4e35a045e
28af88a4cdf73a75d35c04e9ac26888b59eb4d79
diff --git a/apps/docs/src/guide/contracts/custom-contract-calls.md b/apps/docs/src/guide/contracts/custom-contract-calls.md new file mode 100644 index 00000000000..97757c869f2 --- /dev/null +++ b/apps/docs/src/guide/contracts/custom-contract-calls.md @@ -0,0 +1,29 @@ +# Custom Contract Call + +In certain scenarios, yo...
[ "apps/docs/src/guide/contracts/custom-contract-calls.md" ]
[ { "comment": "```suggestion\r\nSkipping this step prevents the SDK from overwriting the prepared transaction and ensures the custom logic remains intact, such as using a predicate as the fee payer.\r\n```", "path": "apps/docs/src/guide/contracts/custom-contract-calls.md", "hunk": "@@ -0,0 +1,14 @@\n+# C...
true
FuelLabs/fuels-ts
3,886
issue_to_patch
Better error messages for predicate setData The current encoding error messages were weak on details and should be improved. > [!NOTE] > - Incoming from https://github.com/FuelLabs/fuels-ts/discussions/1545 Typegen'd `PredicateData` must be mandatory when predicate has required arguments Consider the following p...
fix!: enforce `predicateData` when predicate has arguments
- Closes #3771 - Closes #1552 # Release notes In this release, we: - Enforced Predicate's `data` property when the Predicate has arguments # Breaking Changes Predicates that define arguments must now be instantiated with the data property. It is no longer allowed to omit data when the predicate expects ...
842e0f392c6f349b051fefa6ffd8684390900cb5
4bf3f1fdc55cf6c2056714c286eef02a53025dd6
diff --git a/.changeset/loud-bags-deny.md b/.changeset/loud-bags-deny.md new file mode 100644 index 00000000000..d126cfe917f --- /dev/null +++ b/.changeset/loud-bags-deny.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +fix!: enforce `predicateData` when predicate has arguments diff --git a/apps/create-fuels-...
[ ".changeset/loud-bags-deny.md", "apps/create-fuels-counter-guide/src/components/Predicate.tsx", "apps/docs/src/guide/predicates/snippets/deploying-predicates.ts", "packages/account/src/predicate/predicate.ts", "packages/fuel-gauge/src/blob-deploy.test.ts", "packages/fuel-gauge/src/predicate/predicate-conf...
[]
diff --git a/packages/fuel-gauge/src/blob-deploy.test.ts b/packages/fuel-gauge/src/blob-deploy.test.ts index c09330f1f1d..59bb030cc75 100644 --- a/packages/fuel-gauge/src/blob-deploy.test.ts +++ b/packages/fuel-gauge/src/blob-deploy.test.ts @@ -18,7 +18,7 @@ import { describe('deploying blobs', () => { function dec...
true
FuelLabs/fuels-ts
3,887
issue_to_patch
`waitForPreConfirmation` Does Not Terminate Subscription Immediately When using `transactionResponse.waitForPreConfirmation`, the TS SDK listens for subscription updates—either via `statusChange` or `submitAndAwait`—until the transaction reaches one of the `preconfirmation` statuses: `PreconfirmationSuccess` or `Preco...
fix: close subscription after `Preconfirmation` status when applicable
- Closes #3888 # Release notes In this release, we: - Close subscription after `Preconfirmation` when another status is not awaited by the user # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **revie...
388ad982771a06e73334275c2c96eed8402057d9
eae817ef4ded37f7122a2a8bf25b5d2d65913916
diff --git a/.changeset/rare-kids-grab.md b/.changeset/rare-kids-grab.md new file mode 100644 index 00000000000..c0f63450039 --- /dev/null +++ b/.changeset/rare-kids-grab.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +fix: close subscription after `Preconfirmation` status when applicable diff --git a/packag...
[ ".changeset/rare-kids-grab.md", "packages/account/src/providers/provider.test.ts", "packages/account/src/providers/transaction-response/transaction-response.ts" ]
[]
diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index 48a087ae479..cc56870bfd2 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -25,6 +25,7 @@ import { mockIncompatibleVersions } from '../...
true
FuelLabs/fuels-ts
3,885
issue_to_patch
Reintroduction `setData` for the Predicate # Summary We previously had a method to `setData` on a predicate; however, this was removed. We should reintroduce this method to update the predicate data. It should also validate the data that is being passed, and an error should be thrown early.
feat: add `Predicate` method `setData`
- Closes #3818 # Release notes In this release, we: - Added method `setData` to `Predicate` class # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR** myself (preferably, on...
8889cd7950256ab2d810483c6ea2a0c788490181
e4747b811731aae2858f5b65bc041b8c9d451244
diff --git a/.changeset/curvy-coats-laugh.md b/.changeset/curvy-coats-laugh.md new file mode 100644 index 00000000000..e9d35b2b933 --- /dev/null +++ b/.changeset/curvy-coats-laugh.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +feat: add `Predicate` method `setData` diff --git a/apps/docs/src/guide/predicate...
[ ".changeset/curvy-coats-laugh.md", "apps/docs/src/guide/predicates/methods.md", "apps/docs/src/guide/predicates/snippets/methods/modified-data.ts", "apps/docs/src/guide/predicates/snippets/methods/no-modified-data.ts", "apps/docs/src/guide/predicates/snippets/methods/set-predicate-new-data.ts", "packages/...
[]
diff --git a/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts b/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts index 900e991140b..b6b18a25d32 100644 --- a/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-arguments.test.ts @@ -117...
true
FuelLabs/fuels-ts
3,883
issue_to_patch
chore: fix flaky Vitest tests in browser environment
# Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR** myself (preferably, on GH UI) - [x] I **described** all **Breaking Changes** (or there's none)
f778fe4298aa1a7d7fc8e80624884d01ca7307ba
0795d514dd87d3d788fc5dee57690312862af2e6
diff --git a/.changeset/eighty-lies-end.md b/.changeset/eighty-lies-end.md new file mode 100644 index 00000000000..03a2355f099 --- /dev/null +++ b/.changeset/eighty-lies-end.md @@ -0,0 +1,4 @@ +--- +--- + +chore: fix flaky Vitest tests in browser environment diff --git a/packages/fuels/src/setup-launch-node-server.ts b...
[ ".changeset/eighty-lies-end.md", "packages/fuels/src/setup-launch-node-server.ts", "vitest.browser.config.mts" ]
[]
true
FuelLabs/fuels-ts
3,882
issue_to_patch
Remove `demo-react-cra` app `create-react-app` has been [sunset](https://react.dev/blog/2025/02/14/sunsetting-create-react-app) by the react team so there's no point in us keeping this app alive. We should also consider removing `demo-nextjs` and `demo-react-vite` because we already have the templates for nextjs and ...
chore: sunsetting `demo-react-cra`
- Closes #3801 # Release notes In this release, we: - Sunsetted the `demo-react-app` # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR** myself (preferably, on GH UI) - [...
1b9e399c5503372604a9f08ce975e13b0ebbb110
6b39299053e7370fad96123be181e1cfe2023556
diff --git a/.changeset/config.json b/.changeset/config.json index ea7d2ddbcae..9bed09ca20c 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -11,7 +11,6 @@ "docs", "demo-fuels", "demo-bun-fuels", - "demo-react-cra", "demo-react-vite", "demo-nextjs", "demo-node-esm", d...
[ ".changeset/config.json", ".eslintignore", ".prettierignore", "apps/demo-react-cra/.gitignore", "apps/demo-react-cra/CHANGELOG.md", "apps/demo-react-cra/README.md", "apps/demo-react-cra/package.json", "apps/demo-react-cra/public/favicon.ico", "apps/demo-react-cra/public/index.html", "apps/demo-rea...
[]
diff --git a/apps/demo-react-cra/src/App.test.tsx b/apps/demo-react-cra/src/App.test.tsx deleted file mode 100644 index ed5416b7996..00000000000 --- a/apps/demo-react-cra/src/App.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import { render } from "@testing-library/react"; -import App from "./App"...
true
FuelLabs/fuels-ts
3,880
issue_to_patch
ci(release): `v0.100.6` @ `master`
# Summary In this release, we: - Made connector `sendTransaction` return `TransactionResponse` instead `TransactionResponseJson` # Chores - [#3879](https://github.com/FuelLabs/fuels-ts/pull/3879) - Made connector returns `TransactionResponse` type, by [@Torres-ssf](https://github.com/Torres-ssf)
303379c7eb329993455b4194ce4c181d16e40ee3
5ed2f415171b647718cfb8db10389e3920dc4b32
diff --git a/.changeset/cyan-oranges-smash.md b/.changeset/cyan-oranges-smash.md deleted file mode 100644 index 1f40631fe35..00000000000 --- a/.changeset/cyan-oranges-smash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/account": patch ---- - -chore: made connector returns `TransactionResponse` type diff --git a/inte...
[ ".changeset/cyan-oranges-smash.md", "internal/check-imports/CHANGELOG.md", "internal/check-imports/package.json", "packages/abi-coder/CHANGELOG.md", "packages/abi-coder/package.json", "packages/abi-typegen/CHANGELOG.md", "packages/abi-typegen/package.json", "packages/account/CHANGELOG.md", "packages...
[]
true
FuelLabs/fuels-ts
3,879
issue_to_patch
chore: made connector returns `TransactionResponse` type
# Release notes In this release, we: - Made connector `sendTransaction` return `TransactionResponse` instead `TransactionResponseJson` # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **...
7f094bbfa577d717977f88e33afae1afca7e17ba
66ad3c9d9e1743396d30d8f9689c20eb5ab6ec57
diff --git a/.changeset/cyan-oranges-smash.md b/.changeset/cyan-oranges-smash.md new file mode 100644 index 00000000000..1f40631fe35 --- /dev/null +++ b/.changeset/cyan-oranges-smash.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +chore: made connector returns `TransactionResponse` type diff --git a/packages...
[ ".changeset/cyan-oranges-smash.md", "packages/account/src/account.ts", "packages/account/src/connectors/fuel-connector.ts", "packages/account/src/providers/index.ts", "packages/account/src/providers/utils/transaction-response-serialization.ts", "packages/account/test/fixtures/mocked-connector.ts", "pack...
[]
diff --git a/packages/account/test/fixtures/mocked-connector.ts b/packages/account/test/fixtures/mocked-connector.ts index 2e4dd63a99d..1d39d527019 100644 --- a/packages/account/test/fixtures/mocked-connector.ts +++ b/packages/account/test/fixtures/mocked-connector.ts @@ -11,7 +11,7 @@ import type { Network, Sele...
true
FuelLabs/fuels-ts
3,874
issue_to_patch
ci(release): `v0.100.5` @ `master`
# Summary In this release, we: - Implemented helpers to serialize/deserialize `TransactionResponse` - Fixed error with missing `CALL` receipt in `getAllDecodedLogs` - Fixed `Provider` auto-refetch strategy # Features - [#3878](https://github.com/FuelLabs/fuels-ts/pull/3878) - Implement methods to serialize/deserializ...
416e9e76d5f36e32b796ec26480a5daf33b9a87a
8452d3e52144082130dbba2fc2bd93898fa1ec6b
diff --git a/.changeset/bright-steaks-wave.md b/.changeset/bright-steaks-wave.md deleted file mode 100644 index 6aed675dfc2..00000000000 --- a/.changeset/bright-steaks-wave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/account": patch ---- - -fix: ensure contract call receipt exists when decoding logs diff --git a/....
[ ".changeset/bright-steaks-wave.md", ".changeset/khaki-zoos-cough.md", ".changeset/nine-games-arrive.md", "internal/check-imports/CHANGELOG.md", "internal/check-imports/package.json", "packages/abi-coder/CHANGELOG.md", "packages/abi-coder/package.json", "packages/abi-typegen/CHANGELOG.md", "packages/...
[]
true
FuelLabs/fuels-ts
3,878
issue_to_patch
Implement method to serialize/deserialize `TransactionResponse` We must implement two other methods to serialize and deserialize a `TransactionResponse` instance to exchange it between the SDK vs. Connectors/Wallet via JSON RPC. This is necessary for the conclusion of: - https://github.com/FuelLabs/fuel-connectors/iss...
feat: implement methods to serialize/deserialize `TransactionResponse`
- Closes #3877 # Release notes In this release, we: - Implemented helpers to serialize/deserialize `TransactionResponse` # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR**...
0a8b276e74f3ba26f5151cbcb562c37633973ada
dca89618a1583e460e4e756c39cdf0c08b93ed81
diff --git a/.changeset/nine-games-arrive.md b/.changeset/nine-games-arrive.md new file mode 100644 index 00000000000..1e84841da9e --- /dev/null +++ b/.changeset/nine-games-arrive.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +feat: implement methods to serialize/deserialize `TransactionResponse` diff --git...
[ ".changeset/nine-games-arrive.md", "packages/account/src/account.ts", "packages/account/src/connectors/fuel-connector.ts", "packages/account/src/providers/transaction-request/transaction-request.ts", "packages/account/src/providers/transaction-response/transaction-response.ts", "packages/account/src/provi...
[]
diff --git a/packages/account/src/providers/utils/transaction-response-serialization.test.ts b/packages/account/src/providers/utils/transaction-response-serialization.test.ts new file mode 100644 index 00000000000..f7d792af30b --- /dev/null +++ b/packages/account/src/providers/utils/transaction-response-serialization.t...
true
FuelLabs/fuels-ts
3,869
issue_to_patch
Provider re-requesting chain + node config unnecessarily # Summary We have logic to re-fetch the chain + node info, given the consensus parameters change (indicating a `fuel-core` update): https://github.com/FuelLabs/fuels-ts/blob/3af8692471a6bfd865448cdcd51b8536dcbf9a40/packages/account/src/providers/provider.ts#L1...
fix: provider auto-refetch
- Closes #3810 # Release notes In this release, we: - Fixed `Provider` auto-refetch strategy # Checklist - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR** myself (preferably, on G...
444b80eaec148961f1317479d0b35f3dbef7fcc8
caf95048b0d07a5478e35991431aff68943a7c8c
diff --git a/.changeset/khaki-zoos-cough.md b/.changeset/khaki-zoos-cough.md new file mode 100644 index 00000000000..b3a5dfa4291 --- /dev/null +++ b/.changeset/khaki-zoos-cough.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +fix: provider auto-refetch diff --git a/packages/account/src/providers/operations.gr...
[ ".changeset/khaki-zoos-cough.md", "packages/account/src/providers/operations.graphql", "packages/account/src/providers/provider.test.ts", "packages/account/src/providers/provider.ts", "packages/account/src/providers/utils/serialization.ts", "packages/account/test/fixtures/chain.ts" ]
[]
diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index c7426adb4c9..48a087ae479 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -2312,10 +2312,23 @@ describe('Provider', () => { const...
true
FuelLabs/sway
7,653
issue_to_patch
Improve `storage_benchmarks` tooling
## Description This PR reworks how storage benchmark results are collected and compared. Results are no longer accumulated in RESULTS.md; instead, each run saves its output to a timestamped file in the `perf_out` folder, and diffs are computed between any two such files. Benchmarks can also be run as a `just` recipe...
baa7a253690c0ebde40222c8d5ea550ded9dd395
1bf4b0b1cb438fa64439bc328084309ca28206c0
diff --git a/justfile b/justfile index a19867aec25..6eaf8248f8b 100644 --- a/justfile +++ b/justfile @@ -58,10 +58,16 @@ perf-in-lang filter='': ./test/src/in_language_tests/run_in_language_tests.sh --release {{filter}} | tee /dev/stderr | ./scripts/perf/extract-gas-usages.sh > "$outfile" echo "Gas usages wri...
[ "justfile", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/README.md", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/RESULTS.md", "test/src/e2e_vm_tests/test_programs/should_pass/stora...
[ { "comment": "### Perf diff output name collision\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`perf_diff.sh` names its CSV and Markdown outputs using only the ten-digit timestamps parsed from the two input filenames. Any two comparisons that share the same before/after timestamp pair write to the same...
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore b/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore index 13bad1647e4..fd738c1eec6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore +++ b/test/src/e2e_vm_tests...
true
FuelLabs/sway
7,653
comment_to_fix
Improve `storage_benchmarks` tooling
### Perf diff output name collision **Medium Severity** <!-- DESCRIPTION START --> `perf_diff.sh` names its CSV and Markdown outputs using only the ten-digit timestamps parsed from the two input filenames. Any two comparisons that share the same before/after timestamp pair write to the same `perf_out` paths, so a lat...
baa7a253690c0ebde40222c8d5ea550ded9dd395
1bf4b0b1cb438fa64439bc328084309ca28206c0
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/perf_diff.sh b/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/perf_diff.sh index 5d74fb9a98c..955c3c13969 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/perf_diff.sh +++ b/test/src/e2e_vm...
[ "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/perf_diff.sh" ]
[ { "comment": "### Perf diff output name collision\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`perf_diff.sh` names its CSV and Markdown outputs using only the ten-digit timestamps parsed from the two input filenames. Any two comparisons that share the same before/after timestamp pair write to the same...
true
FuelLabs/sway
7,653
comment_to_fix
Improve `storage_benchmarks` tooling
### perf_out diff files not gitignored **Low Severity** <!-- DESCRIPTION START --> `perf_diff.sh` now writes `.perf-diff.csv` and `.perf-diff.md` under `perf_out/`, and `perf_diff_stats.sh` writes `.perf-diff-stats.md` beside those CSVs. The ignore rules only cover `perf_out/*.txt` and root-level `*.perf-diff.*` patt...
baa7a253690c0ebde40222c8d5ea550ded9dd395
1bf4b0b1cb438fa64439bc328084309ca28206c0
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore b/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore index 13bad1647e4..fd738c1eec6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore +++ b/test/src/e2e_vm_tests...
[ "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/.gitignore" ]
[ { "comment": "### perf_out diff files not gitignored\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\n`perf_diff.sh` now writes `.perf-diff.csv` and `.perf-diff.md` under `perf_out/`, and `perf_diff_stats.sh` writes `.perf-diff-stats.md` beside those CSVs. The ignore rules only cover `perf_out/*.txt` and root...
true
FuelLabs/sway
7,654
issue_to_patch
IR tests snapshots
## Description This PR is a necessary change for https://github.com/FuelLabs/sway/pull/7646. Some IR tests have a bug: their harness is expecting some passes to return `modified = true` even when the pass is not modifying anything. To make sure that #7646 is NOT changing the optimisation itself, but only fixing t...
65d0272fffd7e4cf201755499e286e09c20028bb
c044fa73051a35d59d72daa22c57c8092e5397bd
diff --git a/Cargo.lock b/Cargo.lock index 47633dd5ecd..c542d09a12f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7686,6 +7686,7 @@ dependencies = [ "downcast-rs", "filecheck", "indexmap 2.14.0", + "insta", "itertools 0.13.0", "once_cell", "peg", @@ -7697,6 +7698,7 @@ dependencies = [ "sway-ir-macros", "...
[ "Cargo.lock", "justfile", "sway-ir/Cargo.toml", "sway-ir/tests/ccp/ccp1.ir.snap", "sway-ir/tests/constants/cbr_cmp_fold.ir.snap", "sway-ir/tests/constants/u256_cmp.ir.snap", "sway-ir/tests/constants/u256_ops.ir.snap", "sway-ir/tests/cse/cse1.ir.snap", "sway-ir/tests/cse/cse2.ir.snap", "sway-ir/tes...
[ { "comment": "### Snapshot failures silently ignored\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`insta::assert_snapshot!` runs inside `catch_unwind` and the result is discarded, so a snapshot mismatch no longer fails the test. Regression coverage from the new `.ir.snap` files is effectively optional wh...
diff --git a/sway-ir/tests/ccp/ccp1.ir.snap b/sway-ir/tests/ccp/ccp1.ir.snap new file mode 100644 index 00000000000..8dff6421cb8 --- /dev/null +++ b/sway-ir/tests/ccp/ccp1.ir.snap @@ -0,0 +1,36 @@ +--- +source: sway-ir/tests/tests.rs +--- +Modified: true + +script { + fn test1(p: u64) -> u64 { + entry(p: u64)...
true
FuelLabs/sway
7,654
comment_to_fix
IR tests snapshots
### Snapshot failures silently ignored **High Severity** <!-- DESCRIPTION START --> `insta::assert_snapshot!` runs inside `catch_unwind` and the result is discarded, so a snapshot mismatch no longer fails the test. Regression coverage from the new `.ir.snap` files is effectively optional whenever FileCheck still pass...
65d0272fffd7e4cf201755499e286e09c20028bb
c044fa73051a35d59d72daa22c57c8092e5397bd
diff --git a/sway-ir/tests/tests.rs b/sway-ir/tests/tests.rs index 2ede1eb7358..acd491875d8 100644 --- a/sway-ir/tests/tests.rs +++ b/sway-ir/tests/tests.rs @@ -1,4 +1,7 @@ -use std::path::PathBuf; +use std::{ + panic::catch_unwind, + path::{Path, PathBuf}, +}; use itertools::Itertools; use sway_features::Exp...
[ "sway-ir/tests/tests.rs" ]
[ { "comment": "### Snapshot failures silently ignored\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`insta::assert_snapshot!` runs inside `catch_unwind` and the result is discarded, so a snapshot mismatch no longer fails the test. Regression coverage from the new `.ir.snap` files is effectively optional wh...
true
FuelLabs/sway
7,652
issue_to_patch
Fix `forc-fmt` issues with displaced comments In the `StorageVec` implementation given in #7649 `forc-fmt` displaced some of the comments. The formatting looks weird, but it was left in the PR to satisfy the `forc-fmt-check-sway-lib-std` CI step. Here is the diff that shows displaced formatting: ``` diff --git a/swa...
Fix swayfmt comment placement after multibyte comments
Fixes #7651. ## Description This fixes `forc fmt` displacing line comments after earlier inserted comments contain multibyte characters such as `≥`. The formatter compares parser leaf spans and reinserts comments into formatted code. Those spans are byte offsets, but the comment insertion path returned the inserted ...
e6c1979e32fe73b005afc3bd1ba7f12dd7be4c15
64edabd7ff936527518251886a056c0d7a33a497
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 32cea254387..26c697b3386 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -1351,7 +1351,9 @@ impl<V> StorageKey<StorageVec<V>> { // requires the offset t...
[ "sway-lib-std/src/storage/storage_vec.sw", "swayfmt/src/comments.rs", "swayfmt/tests/mod.rs" ]
[]
diff --git a/swayfmt/tests/mod.rs b/swayfmt/tests/mod.rs index c9276e42cc0..fca43138bf5 100644 --- a/swayfmt/tests/mod.rs +++ b/swayfmt/tests/mod.rs @@ -62,6 +62,108 @@ fn const_spacing() { ) } +#[test] +fn statement_comments_in_impl_function_body_keep_statement_indentation() { + check( + indoc! {r#" ...
true
FuelLabs/sway
7,649
issue_to_patch
Implement chunk-based dynamic storage `StorageVec`
## Description This PR implements a chunk-based dynamic storage `StorageVec<V>`: - vec content is stored in consecutive dynamic storage slots each holding at most `CHUNK_MAX_SIZE` bytes of element data. - all slots hold the same maximum number of elements: `CHUNK_MAX_SIZE / size_of::<V>()`. - individual elements ...
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/generate_storage_vec_bench.sh", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/storage_fields/src/main.sw", "test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/st...
[ { "comment": "### Debug TODO comments left in\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nSeveral new `const SIZE_OF_V` lines in `remove`, `insert`, `store_vec`, and `load_vec` carry inline `TODO-IG!: Report this bug.` notes. These read as temporary author debugging markers, not API documentation, and we...
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/generate_storage_vec_bench.sh b/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/generate_storage_vec_bench.sh index 4a9d86f00f6..e6365642aec 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/storage_benchmarks/...
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
### Debug TODO comments left in **Low Severity** <!-- DESCRIPTION START --> Several new `const SIZE_OF_V` lines in `remove`, `insert`, `store_vec`, and `load_vec` carry inline `TODO-IG!: Report this bug.` notes. These read as temporary author debugging markers, not API documentation, and were introduced in this chang...
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "### Debug TODO comments left in\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nSeveral new `const SIZE_OF_V` lines in `remove`, `insert`, `store_vec`, and `load_vec` carry inline `TODO-IG!: Report this bug.` notes. These read as temporary author debugging markers, not API documentation, and we...
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
See my comments.
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "See my comments.", "path": "sway-lib-std/src/storage/storage_vec.sw", "hunk": "@@ -1221,6 +1250,42 @@ impl<V> StorageKey<StorageVec<V>> {\n // /// True if the `StorageVec` stores a storage type, i.e., if `V` is a storage type.\n // const STORES_STORAGE_TYPE: bool = __size_of::<V>()...
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
Is ' None ' correct here? We should return an instance of the ZST, right? Otherwise, patterns like `while let Some(_) = v.pop()` will not work. TBH, I am not sure how to create the ZST generically here.
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "Is ' None ' correct here? We should return an instance of the ZST, right? Otherwise, patterns like `while let Some(_) = v.pop()` will not work.\n\nTBH, I am not sure how to create the ZST generically here.", "path": "sway-lib-std/src/storage/storage_vec.sw", "hunk": "@@ -1328,33 +1408,28 @...
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
### Nested get wrong StorageKey slot **High Severity** <!-- DESCRIPTION START --> For nested storage element types, `get` builds `StorageKey` with the per-index `sha256` hash as both `slot` and `field_id`, instead of using the vector’s `field_id()` as `slot` and the hash only as `field_id`. Reads and writes through t...
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "### Nested get wrong StorageKey slot\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nFor nested storage element types, `get` builds `StorageKey` with the per-index `sha256` hash as both `slot` and `field_id`, instead of using the vector’s `field_id()` as `slot` and the hash only as `field_id`....
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
### Element larger than chunk size **High Severity** <!-- DESCRIPTION START --> When `__size_of::&lt;V&gt;()` exceeds `CHUNK_MAX_SIZE` (1024), `ELEMS_PER_SLOT` becomes zero and `index / ELEMS_PER_SLOT` divides by zero. The layout also requires each element to fit in one chunk, so types larger than the chunk limit are...
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "### Element larger than chunk size\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nWhen `__size_of::&lt;V&gt;()` exceeds `CHUNK_MAX_SIZE` (1024), `ELEMS_PER_SLOT` becomes zero and `index / ELEMS_PER_SLOT` divides by zero. The layout also requires each element to fit in one chunk, so types larg...
true
FuelLabs/sway
7,649
comment_to_fix
Implement chunk-based dynamic storage `StorageVec`
### Clear drops extra chunk slots **Medium Severity** <!-- DESCRIPTION START --> After this change, vector elements live in `field_id()`, `field_id()+1`, and further chunk slots. Benchmarks and docs still use `storage.vec.clear()`, which (via `StorageKey` for zero-sized `StorageVec`) only clears a single slot at `fie...
ac933ff4f16f0e726b099752806b503ad3836627
56b5d54eb0a47fbf345081f8ea74739eff875c92
diff --git a/sway-lib-std/src/storage/storage_vec.sw b/sway-lib-std/src/storage/storage_vec.sw index 369b7de24dc..32cea254387 100644 --- a/sway-lib-std/src/storage/storage_vec.sw +++ b/sway-lib-std/src/storage/storage_vec.sw @@ -65,6 +65,11 @@ pub struct StorageVec<V> {} /// - `StorageVec<StorageMap<u64, b256>>` ///...
[ "sway-lib-std/src/storage/storage_vec.sw" ]
[ { "comment": "### Clear drops extra chunk slots\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nAfter this change, vector elements live in `field_id()`, `field_id()+1`, and further chunk slots. Benchmarks and docs still use `storage.vec.clear()`, which (via `StorageKey` for zero-sized `StorageVec`) only c...
true
FuelLabs/sway
7,636
issue_to_patch
Fix redundant ops
## Description We have been considering any `NOOP`, and others, as redundant, but in reality they are only redundant if their const def registers are not read by the immediate op. This PR takes this into consideration. ## Checklist - [ ] I have linked to any relevant issues. - [x] I have commented my code,...
cf225bed222b6bc8849cfa7bcfdb9d2a6ae7aac5
7575fe5b2b56f1d8bdc4c5283324d25c90f495da
diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 90ecbdb9768..41ddfe8191f 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizatio...
[ "sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs", "sway-core/src/asm_generation/fuel/optimizations/misc.rs", "sway-core/src/asm_generation/fuel/optimizations/mod.rs", "sway-core/src/asm_lang/virtual_ops.rs", "sway-core/src/asm_lang/virtual_register.rs" ]
[ { "comment": "Nitpick. Nested `if`s with two `else`s looks like a lot of code... \n```suggestion\n let remove = remove && ops.peek().map(|next_op| op.def_const_registers().intersection(&next_op.use_registers()).count()\n == 0).unwrap_or(true);\n```", "path": "sway-core/src/asm_generation/fuel/opt...
true
FuelLabs/sway
7,636
comment_to_fix
Fix redundant ops
Nitpick. Nested `if`s with two `else`s looks like a lot of code... ```suggestion let remove = remove && ops.peek().map(|next_op| op.def_const_registers().intersection(&next_op.use_registers()).count() == 0).unwrap_or(true); ```
cf225bed222b6bc8849cfa7bcfdb9d2a6ae7aac5
7575fe5b2b56f1d8bdc4c5283324d25c90f495da
diff --git a/sway-core/src/asm_generation/fuel/optimizations/misc.rs b/sway-core/src/asm_generation/fuel/optimizations/misc.rs index 9e59fa39a7c..f3229407cbf 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/misc.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/misc.rs @@ -81,7 +81,7 @@ impl Abstract...
[ "sway-core/src/asm_generation/fuel/optimizations/misc.rs" ]
[ { "comment": "Nitpick. Nested `if`s with two `else`s looks like a lot of code... \n```suggestion\n let remove = remove && ops.peek().map(|next_op| op.def_const_registers().intersection(&next_op.use_registers()).count()\n == 0).unwrap_or(true);\n```", "path": "sway-core/src/asm_generation/fuel/opt...
true
FuelLabs/sway
7,636
comment_to_fix
Fix redundant ops
Nitpick. ```suggestion new_ops.push(op.clone()); ```
cf225bed222b6bc8849cfa7bcfdb9d2a6ae7aac5
7575fe5b2b56f1d8bdc4c5283324d25c90f495da
diff --git a/sway-core/src/asm_generation/fuel/optimizations/misc.rs b/sway-core/src/asm_generation/fuel/optimizations/misc.rs index 9e59fa39a7c..f3229407cbf 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/misc.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/misc.rs @@ -81,7 +81,7 @@ impl Abstract...
[ "sway-core/src/asm_generation/fuel/optimizations/misc.rs" ]
[ { "comment": "Nitpick.\n```suggestion\n new_ops.push(op.clone());\n```", "path": "sway-core/src/asm_generation/fuel/optimizations/misc.rs", "hunk": "@@ -92,21 +92,89 @@ impl AbstractInstructionSet {\n self\n }\n \n- pub(crate) fn remove_redundant_ops(mut self) -> AbstractIn...
true
FuelLabs/sway
7,629
issue_to_patch
Consider optimizing `mcp dest src $zero` away At first look, it looks like `mcp dest src $zero` can be safely optimized away (with respect to cleaning the `$err`, of course). Even if `dest == src` FuelVM will not panic, so except for `$err` reset as in all opcodes, there should be no side-effects. We should take a c...
Optimize away zero-length MCP/MCPI instructions
## Description `MCP` with length=0 does nothing at runtime in FuelVM: no panic, no memory change. It resets `$err` to 0, but every instruction does that anyway. So we can safely strip these out. This adds two match arms to `remove_redundant_ops()`: - `MCP(_, _, len)` where `len` is `$zero` (set by constant propagatio...
b556c08b9756a84623c9171ec4c32e72e3970053
8d92e1af0a83adeb50949f28568b38ed824b8b05
diff --git a/sway-core/src/asm_generation/fuel/optimizations/misc.rs b/sway-core/src/asm_generation/fuel/optimizations/misc.rs index 7fbff419eab..9e59fa39a7c 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/misc.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/misc.rs @@ -1,6 +1,8 @@ use super::sup...
[ "sway-core/src/asm_generation/fuel/optimizations/misc.rs", "test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/stdout.snap", "test/src/ir_generation/tests/mcp_zero_len.sw" ]
[ { "comment": "To get address semantics for the pointers passed to `asm`, we need to take addresses, otherwise it is interpreted as `mcp` from the absolute address 42 to absolute address 0.\n```suggestion\n asm(dst_ptr: __addr_of(dst), src_ptr: __addr_of(src), zero: 0u64) {\n```", "path": "test/src/ir_gen...
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/stdout.snap index 70e05c8bb04..032d98ee5c9 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/stdout...
true
FuelLabs/sway
7,629
comment_to_fix
Optimize away zero-length MCP/MCPI instructions
To get address semantics for the pointers passed to `asm`, we need to take addresses, otherwise it is interpreted as `mcp` from the absolute address 42 to absolute address 0. ```suggestion asm(dst_ptr: __addr_of(dst), src_ptr: __addr_of(src), zero: 0u64) { ```
b556c08b9756a84623c9171ec4c32e72e3970053
8d92e1af0a83adeb50949f28568b38ed824b8b05
diff --git a/test/src/ir_generation/tests/mcp_zero_len.sw b/test/src/ir_generation/tests/mcp_zero_len.sw new file mode 100644 index 00000000000..288fe3e9a37 --- /dev/null +++ b/test/src/ir_generation/tests/mcp_zero_len.sw @@ -0,0 +1,26 @@ +// target-fuelvm +script; + +fn main() -> u64 { + let src: u64 = 42; + let...
[ "test/src/ir_generation/tests/mcp_zero_len.sw" ]
[ { "comment": "To get address semantics for the pointers passed to `asm`, we need to take addresses, otherwise it is interpreted as `mcp` from the absolute address 42 to absolute address 0.\n```suggestion\n asm(dst_ptr: __addr_of(dst), src_ptr: __addr_of(src), zero: 0u64) {\n```", "path": "test/src/ir_gen...
true
FuelLabs/sway
7,629
comment_to_fix
Optimize away zero-length MCP/MCPI instructions
Let's also have a test for `mcpi` here.
b556c08b9756a84623c9171ec4c32e72e3970053
8d92e1af0a83adeb50949f28568b38ed824b8b05
diff --git a/test/src/ir_generation/tests/mcp_zero_len.sw b/test/src/ir_generation/tests/mcp_zero_len.sw new file mode 100644 index 00000000000..288fe3e9a37 --- /dev/null +++ b/test/src/ir_generation/tests/mcp_zero_len.sw @@ -0,0 +1,26 @@ +// target-fuelvm +script; + +fn main() -> u64 { + let src: u64 = 42; + let...
[ "test/src/ir_generation/tests/mcp_zero_len.sw" ]
[ { "comment": "Let's also have a test for `mcpi` here.", "path": "test/src/ir_generation/tests/mcp_zero_len.sw", "hunk": "@@ -0,0 +1,20 @@\n+// target-fuelvm\n+script;\n+\n+fn main() -> u64 {\n+ let src: u64 = 42;\n+ let mut dst: u64 = 0;\n+ asm(dst_ptr: dst, src_ptr: src, zero: 0u64) {\n+ ...
true
FuelLabs/sway
7,635
issue_to_patch
Optimize execution speed of `in_language` tests
## Description This PR adds optional regex-based filtering to in-language test runs so CI only executes relevant projects for experimental feature-specific variants. Addresses first part of the #7617. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in h...
aa2e3b1d2ea6498cc891ea29d004f96790a0991e
88767d10c466f783b8bdb040334a16dc87290b44
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94c9154ad52..3aa6b53f508 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -545,17 +545,17 @@ jobs: - name: Run In Language Unit Tests (Release) run: ./test/src/in_language_tests/run_in_language_tests.sh --relea...
[ ".github/workflows/ci.yml", "test/src/in_language_tests/run_in_language_tests.sh" ]
[]
diff --git a/test/src/in_language_tests/run_in_language_tests.sh b/test/src/in_language_tests/run_in_language_tests.sh index d09239e82e1..ef503712d5b 100755 --- a/test/src/in_language_tests/run_in_language_tests.sh +++ b/test/src/in_language_tests/run_in_language_tests.sh @@ -2,9 +2,12 @@ # Run `forc test` individua...
true
FuelLabs/sway
7,634
issue_to_patch
Bump to 0.71.2 and fix crates.io publish
## Summary - Bump workspace and `sway-lib-std` to **0.71.2** after the failed v0.71.1 crates.io publish (only `sway-utils` 0.71.1 made it up; binaries for v0.71.1 are fine). - Fix publish breakage from **yanked `core2`** (RUSTSEC-2026-0105): `FuelLabs/publish-crates` runs `cargo update` after each crate, which failed ...
54a2d0f9426a577c77e6b556317e34020800eb03
457ce1d19657e7504060ea9ee985a80fc2b4201e
diff --git a/Cargo.lock b/Cargo.lock index 112609114f3..47633dd5ecd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,13 +109,13 @@ dependencies = [ "derive_more 2.1.1", "foldhash", "hashbrown 0.15.5", - "indexmap 2.13.1", + "indexmap 2.14.0", "itoa", "k256", "keccak-asm", "paste", "proptest", - "rand 0....
[ "Cargo.lock", "Cargo.toml", "forc-pkg/Cargo.toml", "forc-pkg/src/source/ipfs.rs", "forc-pkg/src/source/reg/mod.rs", "sway-lib-std/Forc.toml", "sway-lsp/tests/utils/Cargo.toml", "test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap" ]
[ { "comment": "### Local IPFS API call wrong\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nLocal package fetch now issues an HTTP GET to `/api/v0/cat`, but Kubo’s RPC API expects POST and the previous client used `/api/v0/get` for `/ipfs/{cid}` paths. Directory CIDs (typical registry sources) need a tar ar...
diff --git a/sway-lsp/tests/utils/Cargo.toml b/sway-lsp/tests/utils/Cargo.toml index cbb98baae8e..e03a674d3f6 100644 --- a/sway-lsp/tests/utils/Cargo.toml +++ b/sway-lsp/tests/utils/Cargo.toml @@ -16,7 +16,7 @@ normal = ["tower"] assert-json-diff.workspace = true futures = { workspace = true, features = ["async-await...
true
FuelLabs/sway
7,634
comment_to_fix
Bump to 0.71.2 and fix crates.io publish
### Local IPFS API call wrong **High Severity** <!-- DESCRIPTION START --> Local package fetch now issues an HTTP GET to `/api/v0/cat`, but Kubo’s RPC API expects POST and the previous client used `/api/v0/get` for `/ipfs/{cid}` paths. Directory CIDs (typical registry sources) need a tar archive from `get`, not `cat`...
54a2d0f9426a577c77e6b556317e34020800eb03
457ce1d19657e7504060ea9ee985a80fc2b4201e
diff --git a/forc-pkg/src/source/ipfs.rs b/forc-pkg/src/source/ipfs.rs index 7ac1cf08a7e..4a5a027e3bb 100644 --- a/forc-pkg/src/source/ipfs.rs +++ b/forc-pkg/src/source/ipfs.rs @@ -3,12 +3,9 @@ use crate::{ manifest::{self, PackageManifestFile}, source, }; -use anyhow::Result; +use anyhow::{Context, Result};...
[ "forc-pkg/src/source/ipfs.rs" ]
[ { "comment": "### Local IPFS API call wrong\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nLocal package fetch now issues an HTTP GET to `/api/v0/cat`, but Kubo’s RPC API expects POST and the previous client used `/api/v0/get` for `/ipfs/{cid}` paths. Directory CIDs (typical registry sources) need a tar ar...
true
FuelLabs/sway
7,634
comment_to_fix
Bump to 0.71.2 and fix crates.io publish
### Test leaves HOME unset **Low Severity** <!-- DESCRIPTION START --> `test_fetch_with_local_node_post_cat` sets `HOME` to a temporary directory but never restores the previous value. When the `TempDir` is dropped at the end of the test, `HOME` still points at a removed path, which can make later tests in the same p...
54a2d0f9426a577c77e6b556317e34020800eb03
457ce1d19657e7504060ea9ee985a80fc2b4201e
diff --git a/forc-pkg/src/source/ipfs.rs b/forc-pkg/src/source/ipfs.rs index 7ac1cf08a7e..4a5a027e3bb 100644 --- a/forc-pkg/src/source/ipfs.rs +++ b/forc-pkg/src/source/ipfs.rs @@ -3,12 +3,9 @@ use crate::{ manifest::{self, PackageManifestFile}, source, }; -use anyhow::Result; +use anyhow::{Context, Result};...
[ "forc-pkg/src/source/ipfs.rs" ]
[ { "comment": "### Test leaves HOME unset\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\n`test_fetch_with_local_node_post_cat` sets `HOME` to a temporary directory but never restores the previous value. When the `TempDir` is dropped at the end of the test, `HOME` still points at a removed path, which can mak...
true
FuelLabs/sway
7,632
issue_to_patch
fix help link that needs compiler version
## Description Fix required attribute help link. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requir...
f494ba0994ce511398a92b27c4220d299262c364
0597b73bd8e9d57bc4e25dc3b2b5d9195722c955
diff --git a/docs/book/src/advanced/index.md b/docs/book/src/advanced/index.md index 3d1795af288..207936b3f78 100644 --- a/docs/book/src/advanced/index.md +++ b/docs/book/src/advanced/index.md @@ -10,3 +10,4 @@ Advanced concepts. - [Generics and Trait Constraints](./generics_and_trait_constraints.md) - [Assembly](./a...
[ "docs/book/src/advanced/index.md", "sway-error/src/error.rs", "test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap" ]
[]
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap index 9a83e15e125..43e56bdae78 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/attribut...
true
FuelLabs/sway
7,631
issue_to_patch
Bump to 0.71.1
b840704fe007503dd7a391a03ec976a599698f37
e3757f406e53bc2f1fc38a8fd944f062072dd30b
diff --git a/Cargo.lock b/Cargo.lock index 2fb28ed7759..112609114f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2505,7 +2505,7 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "forc" -version = "0.71.0" +version = "0.71.1" dependencies = [ "annotate-snippets", ...
[ "Cargo.lock", "Cargo.toml", "sway-lib-std/Forc.toml" ]
[]
true
FuelLabs/sway
7,575
issue_to_patch
Compiler attribute to guarantee that types are trivially encodable/decodable Contract functions can gain a lot of performance if their inputs are trivially decodable, but today there is no easy way for a developer to check if a type is "trivially decodable" or not. And there is not way to fail compilation if a type is...
Attribute for checking of trivial encoding and decoding
## Description Closes https://github.com/FuelLabs/sway/issues/7567. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/docs/book/spell-check-custom-words.txt b/docs/book/spell-check-custom-words.txt index a45f2308622..eb828999754 100644 --- a/docs/book/spell-check-custom-words.txt +++ b/docs/book/spell-check-custom-words.txt @@ -275,3 +275,9 @@ Preload preloads Preloads VM's +Decodable +Encodable +callee +decodable +enc...
[ "docs/book/spell-check-custom-words.txt", "docs/book/src/SUMMARY.md", "docs/book/src/advanced/trivial_encoding.md", "sway-ast/src/attribute.rs", "sway-ast/src/literal.rs", "sway-core/src/ir_generation.rs", "sway-core/src/ir_generation/compile.rs", "sway-core/src/ir_generation/const_eval.rs", "sway-c...
[ { "comment": "### Debug statement accidentally committed to production\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nA `dbg!` macro call printing `decls_to_check` was left in the production code path of `compile_to_asm`. This runs on every compilation, printing debug output to stderr for all users of th...
diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/intrinsics/intrinsics_args_type_checking/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_fail/language/intrinsics/intrinsics_args_type_checking/stdout.snap index 56e2029359b..5b71435aae0 100644 --- a/test/src/e2e_vm_tests/test_programs/shoul...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Debug statement accidentally committed to production **Medium Severity** <!-- DESCRIPTION START --> A `dbg!` macro call printing `decls_to_check` was left in the production code path of `compile_to_asm`. This runs on every compilation, printing debug output to stderr for all users of the compiler. <!-- DESCRIPTIO...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index 9a1c701bccc..9cffb101efb 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -26,11 +26,18 @@ pub mod source_map; pub mod transform; pub mod type_system; +use crate::decl_engine::DeclEngineGet as _; +use crate::engine_threading::SpannedWithE...
[ "sway-core/src/lib.rs" ]
[ { "comment": "### Debug statement accidentally committed to production\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nA `dbg!` macro call printing `decls_to_check` was left in the production code path of `compile_to_asm`. This runs on every compilation, printing debug output to stderr for all users of th...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Misplaced test: non-trivially-decodable struct in should_pass **High Severity** <!-- DESCRIPTION START --> `MyStruct` is annotated with `#[require(trivially_decodable = "true")]` but contains `bool`, `SomeEnum`, and `Vec<u64>` fields — none of which are trivially decodable. The `MemoryRepresentation` comparison i...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/src/main.sw new file mode 100644 index 00000000000..5422c5d9aa3 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/s...
[ "test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/src/main.sw" ]
[ { "comment": "### Misplaced test: non-trivially-decodable struct in should_pass\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`MyStruct` is annotated with `#[require(trivially_decodable = \"true\")]` but contains `bool`, `SomeEnum`, and `Vec<u64>` fields — none of which are trivially decodable. The `Memor...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Attribute value required but silently ignored in check **Medium Severity** <!-- DESCRIPTION START --> The `Require` attribute kind is configured with `args_expect_values => Yes`, meaning a value like `= "true"` or `= "false"` is syntactically required for each argument. However, the actual check in `compile_entry...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Attribute value required but silently ignored in check\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `Require` attribute kind is configured with `args_expect_values => Yes`, meaning a value like `= \"true\"` or `= \"false\"` is syntactically required for each argument. However, the...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Require attribute check skipped for predicates and contracts **High Severity** <!-- DESCRIPTION START --> `decls_to_check` is extracted from `TyProgram` and forwarded only to `compile_script`. Both `compile_predicate` and `compile_contract` do not accept a `decls_to_check` parameter, and instead always pass `&[]`...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation.rs b/sway-core/src/ir_generation.rs index 3ea644068e1..aedfd27ce96 100644 --- a/sway-core/src/ir_generation.rs +++ b/sway-core/src/ir_generation.rs @@ -11,7 +11,6 @@ use std::{ collections::HashMap, hash::{DefaultHasher, Hasher}, }; - use sway_error::error::CompileEr...
[ "sway-core/src/ir_generation.rs" ]
[ { "comment": "### Require attribute check skipped for predicates and contracts\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`decls_to_check` is extracted from `TyProgram` and forwarded only to `compile_script`. Both `compile_predicate` and `compile_contract` do not accept a `decls_to_check` parameter, an...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Unhandled match arm panics on non-struct decls **High Severity** <!-- DESCRIPTION START --> The `_ => todo!()` catch-all in the `decls_to_check` match will panic at runtime if any non-`StructDecl` variant ends up in the list. The `#[require]` attribute is allowed on enums (`can_annotate_item_kind` returns true fo...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Unhandled match arm panics on non-struct decls\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe `_ => todo!()` catch-all in the `decls_to_check` match will panic at runtime if any non-`StructDecl` variant ends up in the list. The `#[require]` attribute is allowed on enums (`can_annotate...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Vec type replacement corrupts nested generic type suggestions **Low Severity** <!-- DESCRIPTION START --> The `replace(">", "; 64]")` call replaces *all* `>` characters in the type name string, not just the closing one from `Vec<...>`. For types like `Vec<SomeStruct<u64>>`, this produces a malformed suggestion li...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Vec type replacement corrupts nested generic type suggestions\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `replace(\">\", \"; 64]\")` call replaces *all* `>` characters in the type name string, not just the closing one from `Vec<...>`. For types like `Vec<SomeStruct<u64>>`, this pro...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### All fields blamed as non-trivial regardless of actual triviality **Low Severity** <!-- DESCRIPTION START --> The diagnostic loop unconditionally pushes an info message for every field from `all_fields_recursive`, stating each field "is not allowing its owner type to be trivially decodable." Fields that are alread...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### All fields blamed as non-trivial regardless of actual triviality\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe diagnostic loop unconditionally pushes an info message for every field from `all_fields_recursive`, stating each field \"is not allowing its owner type to be trivially decoda...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Test expects failure but lives in should_pass directory **Medium Severity** <!-- DESCRIPTION START --> The `attribute_require` test is located under `should_pass` but the snapshot expects `exit status: 1` with a compilation error. A test that intentionally triggers a compile error belongs in a `should_fail` direc...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap new file mode 100644 index 00000000000..9a83e15e125 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/s...
[ "test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap" ]
[ { "comment": "### Test expects failure but lives in should_pass directory\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `attribute_require` test is located under `should_pass` but the snapshot expects `exit status: 1` with a compilation error. A test that intentionally triggers a compile error belon...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Trivial check skipped for contracts and predicates **Medium Severity** <!-- DESCRIPTION START --> `decls_to_check` is extracted from the program but only passed through to `compile_entry_function` for scripts. For contracts and predicates, `&[]` is hardcoded, so `#[require]` attribute checks silently do nothing. ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Trivial check skipped for contracts and predicates\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`decls_to_check` is extracted from the program but only passed through to `compile_entry_function` for scripts. For contracts and predicates, `&[]` is hardcoded, so `#[require]` attribute c...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Overly broad attribute check collects all attributed structs **Low Severity** <!-- DESCRIPTION START --> The check `!d.attributes.is_empty()` adds every struct with *any* attribute (including doc comments, `#[cfg]`, `#[deprecated]`, etc.) to `decls_to_check`. This is overly broad — only structs with `AttributeKin...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/language/ty/declaration/declaration.rs b/sway-core/src/language/ty/declaration/declaration.rs index f12eeb9fd89..a4888f5c405 100644 --- a/sway-core/src/language/ty/declaration/declaration.rs +++ b/sway-core/src/language/ty/declaration/declaration.rs @@ -1,17 +1,17 @@ use crate::{ decl_e...
[ "sway-core/src/language/ty/declaration/declaration.rs" ]
[ { "comment": "### Overly broad attribute check collects all attributed structs\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe check `!d.attributes.is_empty()` adds every struct with *any* attribute (including doc comments, `#[cfg]`, `#[deprecated]`, etc.) to `decls_to_check`. This is overly broad — only...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Bool runtime representation uses range, breaking triviality equality **Medium Severity** <!-- DESCRIPTION START --> The `range` field on `MemoryRepresentation::Blob` is included in the derived `PartialEq`. The runtime representation for `bool` uses `range: Some(0..2)` while the encoding representation uses `range...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 2169d4aa07c..79cd8c73610 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -28,9 +28,13 @@ use crate::{ types::*, PanicOccurrence, PanicOccurrences, Panickin...
[ "sway-core/src/ir_generation/function.rs" ]
[ { "comment": "### Bool runtime representation uses range, breaking triviality equality\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `range` field on `MemoryRepresentation::Blob` is included in the derived `PartialEq`. The runtime representation for `bool` uses `range: Some(0..2)` while the encoding...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Duplicate test doesn't verify `is_valid` method **Medium Severity** <!-- DESCRIPTION START --> `trivial_bool_when_invalid_is_valid` and `trivial_bool_when_invalid_unwrap` have identical bodies — both call `.unwrap()`. The first test's name implies it verifies that `is_valid()` returns `false` for an invalid value...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 32bb8ef5e88..e5527835fb9 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3,6 +3,8 @@ library; use ::ops::*; use ::raw_ptr::*; use ::raw_slice::*; +use ::slice::*; +use ::error_signals::*; pub struct Buffer { b...
[ "sway-lib-std/src/codec.sw" ]
[ { "comment": "### Duplicate test doesn't verify `is_valid` method\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`trivial_bool_when_invalid_is_valid` and `trivial_bool_when_invalid_unwrap` have identical bodies — both call `.unwrap()`. The first test's name implies it verifies that `is_valid()` returns `...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### No enum type validation for `EnumDiscriminantCount` intrinsic **Medium Severity** <!-- DESCRIPTION START --> `type_check_enum_discriminant_count` validates argument count and type argument count but never verifies the type argument is actually an enum. Since `TrivialEnum<T>` has no generic constraint requiring `T...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs index 4666c48f85b..350086a32aa 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs +++ b/sway-core/src/semantic_analysis/a...
[ "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs" ]
[ { "comment": "### No enum type validation for `EnumDiscriminantCount` intrinsic\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`type_check_enum_discriminant_count` validates argument count and type argument count but never verifies the type argument is actually an enum. Since `TrivialEnum<T>` has no gene...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Trivially encodable check defined but never enforced **Medium Severity** <!-- DESCRIPTION START --> `REQUIRE_ARG_NAME_TRIVIALLY_ENCODABLE` is defined and registered as a valid argument for the `#[require]` attribute, but the checking logic in `compile_entry_function` only checks for `REQUIRE_ARG_NAME_TRIVIALLY_DE...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-ast/src/attribute.rs b/sway-ast/src/attribute.rs index 515d7a43f77..7c26ae939a3 100644 --- a/sway-ast/src/attribute.rs +++ b/sway-ast/src/attribute.rs @@ -65,6 +65,11 @@ pub const ABI_NAME_NAME_ARG_NAME: &str = "name"; pub const EVENT_ATTRIBUTE_NAME: &str = "event"; pub const INDEXED_ATTRIBUTE_NAME:...
[ "sway-ast/src/attribute.rs" ]
[ { "comment": "### Trivially encodable check defined but never enforced\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`REQUIRE_ARG_NAME_TRIVIALLY_ENCODABLE` is defined and registered as a valid argument for the `#[require]` attribute, but the checking logic in `compile_entry_function` only checks for `RE...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Encodable require argument is ignored **Medium Severity** <!-- DESCRIPTION START --> `run_ir_decl_checks` only handles `trivially_decodable` and never processes `trivially_encodable`, even though the attribute parser accepts both keys. Using `#[require(trivially_encodable = ...)]` currently performs no validation...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Encodable require argument is ignored\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`run_ir_decl_checks` only handles `trivially_decodable` and never processes `trivially_encodable`, even though the attribute parser accepts both keys. Using `#[require(trivially_encodable = ...)]` curre...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Require allowed on enums but never checked **Medium Severity** <!-- DESCRIPTION START --> `#[require]` is accepted on enums, but enum declarations are excluded from `TypeMetadata::CheckDecl` collection, so enum annotations never reach the checker. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 42176964-ebb5-4293-8...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/language/ty/declaration/declaration.rs b/sway-core/src/language/ty/declaration/declaration.rs index f12eeb9fd89..a4888f5c405 100644 --- a/sway-core/src/language/ty/declaration/declaration.rs +++ b/sway-core/src/language/ty/declaration/declaration.rs @@ -1,17 +1,17 @@ use crate::{ decl_e...
[ "sway-core/src/language/ty/declaration/declaration.rs" ]
[ { "comment": "### Require allowed on enums but never checked\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`#[require]` is accepted on enums, but enum declarations are excluded from `TypeMetadata::CheckDecl` collection, so enum annotations never reach the checker.\n<!-- DESCRIPTION END -->\n\n<!-- BUGBO...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Const-eval intrinsic branch still unimplemented **High Severity** <!-- DESCRIPTION START --> `Intrinsic::EnumDiscriminantCount` in const-eval calls `todo!()`. Using this intrinsic in any constant-evaluated context will panic the compiler. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: eeabf343-71db-4ae5-beae-0989f...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/const_eval.rs b/sway-core/src/ir_generation/const_eval.rs index fe5f5613517..86ee30a77f5 100644 --- a/sway-core/src/ir_generation/const_eval.rs +++ b/sway-core/src/ir_generation/const_eval.rs @@ -567,44 +567,7 @@ fn const_eval_typed_expr( fn_ref, call_p...
[ "sway-core/src/ir_generation/const_eval.rs" ]
[ { "comment": "### Const-eval intrinsic branch still unimplemented\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`Intrinsic::EnumDiscriminantCount` in const-eval calls `todo!()`. Using this intrinsic in any constant-evaluated context will panic the compiler.\n<!-- DESCRIPTION END -->\n\n<!-- BUGBOT_BUG_ID:...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### `EnumVariantsValues` intrinsic hardcodes `true` for all variants **High Severity** <!-- DESCRIPTION START --> The `EnumVariantsValues` intrinsic always returns `true` for every enum variant via `ConstantContent::new_bool(context, true)`, ignoring whether each variant is actually trivially decodable. This defeats ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 2169d4aa07c..79cd8c73610 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -28,9 +28,13 @@ use crate::{ types::*, PanicOccurrence, PanicOccurrences, Panickin...
[ "sway-core/src/ir_generation/function.rs" ]
[ { "comment": "### `EnumVariantsValues` intrinsic hardcodes `true` for all variants\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe `EnumVariantsValues` intrinsic always returns `true` for every enum variant via `ConstantContent::new_bool(context, true)`, ignoring whether each variant is actually trivial...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Type check hardcodes literal `3`, panics otherwise **High Severity** <!-- DESCRIPTION START --> `type_check_enum_variants_values` only accepts the literal value `3` as the first argument and panics with `todo!()` for any other value. This makes the intrinsic unusable for general purposes and will crash the compil...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs index 4666c48f85b..350086a32aa 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs +++ b/sway-core/src/semantic_analysis/a...
[ "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs" ]
[ { "comment": "### Type check hardcodes literal `3`, panics otherwise\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`type_check_enum_variants_values` only accepts the literal value `3` as the first argument and panics with `todo!()` for any other value. This makes the intrinsic unusable for general purpose...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Out-of-bounds access before bounds check in `is_valid` **High Severity** <!-- DESCRIPTION START --> In `TrivialEnum::is_valid`, `__elem_at(is_decode_trivial_table, discriminant)` accesses the slice at the discriminant index *before* the bounds check `discriminant < is_decode_trivial_table.len()` is evaluated. Whe...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 32bb8ef5e88..e5527835fb9 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3,6 +3,8 @@ library; use ::ops::*; use ::raw_ptr::*; use ::raw_slice::*; +use ::slice::*; +use ::error_signals::*; pub struct Buffer { b...
[ "sway-lib-std/src/codec.sw" ]
[ { "comment": "### Out-of-bounds access before bounds check in `is_valid`\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nIn `TrivialEnum::is_valid`, `__elem_at(is_decode_trivial_table, discriminant)` accesses the slice at the discriminant index *before* the bounds check `discriminant < is_decode_trivial_tab...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Wrong expected argument count in error message **Medium Severity** <!-- DESCRIPTION START --> In `type_check_enum_variants_values`, the check `arguments.len() != 1` correctly validates that exactly one argument is needed, but the error reports `expected: 0`. The error message will mislead users into passing zero ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs index 4666c48f85b..350086a32aa 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs +++ b/sway-core/src/semantic_analysis/a...
[ "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs" ]
[ { "comment": "### Wrong expected argument count in error message\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nIn `type_check_enum_variants_values`, the check `arguments.len() != 1` correctly validates that exactly one argument is needed, but the error reports `expected: 0`. The error message will misle...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### TrivialEnum abi_encode silently discards the inner value **Medium Severity** <!-- DESCRIPTION START --> `TrivialEnum<T>`'s `abi_encode` returns the buffer unchanged without encoding `self.value`. While the trivial encoding path bypasses this method via memcpy, if `abi_encode` is ever called through the non-trivia...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 32bb8ef5e88..e5527835fb9 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3,6 +3,8 @@ library; use ::ops::*; use ::raw_ptr::*; use ::raw_slice::*; +use ::slice::*; +use ::error_signals::*; pub struct Buffer { b...
[ "sway-lib-std/src/codec.sw" ]
[ { "comment": "### TrivialEnum abi_encode silently discards the inner value\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`TrivialEnum<T>`'s `abi_encode` returns the buffer unchanged without encoding `self.value`. While the trivial encoding path bypasses this method via memcpy, if `abi_encode` is ever ca...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Debug trait bound added to monomorphize functions unnecessarily **Low Severity** <!-- DESCRIPTION START --> The `std::fmt::Debug` trait bound was added to `monomorphize` and `monomorphize_with_modpath` generic type parameters. This exists solely to support the commented-out `eprintln!` debug statements in `functi...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/type_system/monomorphization.rs b/sway-core/src/type_system/monomorphization.rs index 70871ea15ba..80327e179bb 100644 --- a/sway-core/src/type_system/monomorphization.rs +++ b/sway-core/src/type_system/monomorphization.rs @@ -276,12 +276,8 @@ where subst_ctx, )?; - value.su...
[ "sway-core/src/type_system/monomorphization.rs" ]
[ { "comment": "### Debug trait bound added to monomorphize functions unnecessarily\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `std::fmt::Debug` trait bound was added to `monomorphize` and `monomorphize_with_modpath` generic type parameters. This exists solely to support the commented-out `eprintln!` ...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Commented-out debug eprintln statements left in code **Low Severity** <!-- DESCRIPTION START --> Multiple commented-out `//eprintln!` debug statements were added across `function_application.rs` (lines 30 and 101) and `method_application.rs` (line 1017). These are development-time debugging artifacts that clutter...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/function_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/function_application.rs index 0f75245398d..288b068983e 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/functi...
[ "sway-core/src/semantic_analysis/ast_node/expression/typed_expression/function_application.rs" ]
[ { "comment": "### Commented-out debug eprintln statements left in code\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nMultiple commented-out `//eprintln!` debug statements were added across `function_application.rs` (lines 30 and 101) and `method_application.rs` (line 1017). These are development-time debug...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Vec/String help messages never shown due to path mismatch **Medium Severity** <!-- DESCRIPTION START --> The special-case help messages for `Vec` and `String` types are never triggered. The checks use fully-qualified paths (`std::vec::Vec<` and `std::string::String`) but `type_as_in_src` comes from `span.as_str()...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### Vec/String help messages never shown due to path mismatch\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe special-case help messages for `Vec` and `String` types are never triggered. The checks use fully-qualified paths (`std::vec::Vec<` and `std::string::String`) but `type_as_in_src...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Recursive struct metadata collection may cause infinite loop **Medium Severity** <!-- DESCRIPTION START --> The new `TypeInfo::Struct` arm in `CollectTypesMetadata for TypeId` calls `TyDecl::StructDecl(...).collect_types_metadata()`, which in turn inspects fields' type IDs. Since `extract_any_including_self` recu...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/type_system/id.rs b/sway-core/src/type_system/id.rs index 6a17fc1aab6..de6cbd9e75a 100644 --- a/sway-core/src/type_system/id.rs +++ b/sway-core/src/type_system/id.rs @@ -12,7 +12,10 @@ use crate::{ DeclEngineGet, DeclEngineGetParsedDecl, DeclEngineInsert, MaterializeConstGenerics, ...
[ "sway-core/src/type_system/id.rs" ]
[ { "comment": "### Recursive struct metadata collection may cause infinite loop\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe new `TypeInfo::Struct` arm in `CollectTypesMetadata for TypeId` calls `TyDecl::StructDecl(...).collect_types_metadata()`, which in turn inspects fields' type IDs. Since `extra...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### `generate_tables` silently swallows parse/compilation errors **Medium Severity** <!-- DESCRIPTION START --> `generate_tables` calls `parse_impl_trait_to_ty_ast_node(...).ok()`, silently discarding any parse or compilation errors when generating the `EnumCodecValues` implementation. If the auto-generated code is m...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs b/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs index 6a7ab2ce415..ffc797b4774 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs +++ b/sway-core/src/sema...
[ "sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs" ]
[ { "comment": "### `generate_tables` silently swallows parse/compilation errors\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\n`generate_tables` calls `parse_impl_trait_to_ty_ast_node(...).ok()`, silently discarding any parse or compilation errors when generating the `EnumCodecValues` implementation. If t...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### HashMap `unwrap()` panics when type key is missing **High Severity** <!-- DESCRIPTION START --> `table.get(&fullname).unwrap()` and `table.get(&field_fullname).unwrap()` will panic if the type's name is absent from the table. The table is built via `filter_map` in `run_ir_decl_checks` (lines 627–636), which silen...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "### HashMap `unwrap()` panics when type key is missing\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`table.get(&fullname).unwrap()` and `table.get(&field_fullname).unwrap()` will panic if the type's name is absent from the table. The table is built via `filter_map` in `run_ir_decl_checks` (...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### `todo!()` in production code panics on unexpected types **Medium Severity** <!-- DESCRIPTION START --> Two `todo!()` macros in the `check_type` closure (line 1171) and `push_help_if_non_trivially_decodable_type` (line 768) will panic at runtime if an unexpected `TypeInfo` variant is encountered. These are reachab...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index 9a1c701bccc..9cffb101efb 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -26,11 +26,18 @@ pub mod source_map; pub mod transform; pub mod type_system; +use crate::decl_engine::DeclEngineGet as _; +use crate::engine_threading::SpannedWithE...
[ "sway-core/src/lib.rs" ]
[ { "comment": "### `todo!()` in production code panics on unexpected types\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nTwo `todo!()` macros in the `check_type` closure (line 1171) and `push_help_if_non_trivially_decodable_type` (line 768) will panic at runtime if an unexpected `TypeInfo` variant is enc...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Shadowed MetadataManager discards state from decl checks context **Medium Severity** <!-- DESCRIPTION START --> A `MetadataManager` is created at line 951 and mutated by `run_decl_checks`, but then a second `let mut md_mgr = MetadataManager::default()` at line 1040 shadows it. Meanwhile, the same `ctx` (IR `Conte...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index 9a1c701bccc..9cffb101efb 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -26,11 +26,18 @@ pub mod source_map; pub mod transform; pub mod type_system; +use crate::decl_engine::DeclEngineGet as _; +use crate::engine_threading::SpannedWithE...
[ "sway-core/src/lib.rs" ]
[ { "comment": "### Shadowed MetadataManager discards state from decl checks context\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nA `MetadataManager` is created at line 951 and mutated by `run_decl_checks`, but then a second `let mut md_mgr = MetadataManager::default()` at line 1040 shadows it. Meanwhile...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### `TrivialBool` methods missing `pub` visibility modifier **High Severity** <!-- DESCRIPTION START --> `TrivialBool`'s `is_valid` and `unwrap` methods are missing the `pub` keyword, making them inaccessible to external users. The documentation explicitly shows users calling `.unwrap()` on `TrivialBool` values. The ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 32bb8ef5e88..e5527835fb9 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3,6 +3,8 @@ library; use ::ops::*; use ::raw_ptr::*; use ::raw_slice::*; +use ::slice::*; +use ::error_signals::*; pub struct Buffer { b...
[ "sway-lib-std/src/codec.sw" ]
[ { "comment": "### `TrivialBool` methods missing `pub` visibility modifier\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\n`TrivialBool`'s `is_valid` and `unwrap` methods are missing the `pub` keyword, making them inaccessible to external users. The documentation explicitly shows users calling `.unwrap()` on...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
nit: I'd prefer to have the decl handled with an enum, so that the `unwrap()` below becomes unnecessary. Perhaps something like this: ```rust enum Ty { Ref(Span), Decl, } ```
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index 9a1c701bccc..9cffb101efb 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -26,11 +26,18 @@ pub mod source_map; pub mod transform; pub mod type_system; +use crate::decl_engine::DeclEngineGet as _; +use crate::engine_threading::SpannedWithE...
[ "sway-core/src/lib.rs" ]
[ { "comment": "nit: I'd prefer to have the decl handled with an enum, so that the `unwrap()` below becomes unnecessary. Perhaps something like this:\n\n```rust\nenum Ty {\n Ref(Span),\n Decl,\n}\n```", "path": "sway-core/src/lib.rs", "hunk": "@@ -1050,6 +1078,195 @@ pub fn parsed_to_ast(\n Ok(t...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
typo: "aray"
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "typo: \"aray\"", "path": "sway-core/src/ir_generation/compile.rs", "hunk": "@@ -576,6 +575,300 @@ pub(super) fn compile_entry_function(\n .map(|f| f.expect(\"entry point should never contain generics\"))\n }\n \n+#[derive(Debug, Clone)]\n+pub enum CheckDecl {\n+ Ref {\n+ tid:...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
This breaks if any nested types are generic
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs index 1a2b95e9ae3..153d420b6c8 100644 --- a/sway-core/src/ir_generation/compile.rs +++ b/sway-core/src/ir_generation/compile.rs @@ -1,32 +1,42 @@ +use super::{ + const_eval::{compile_const_decl, LookupEnv}, + convert::con...
[ "sway-core/src/ir_generation/compile.rs" ]
[ { "comment": "This breaks if any nested types are generic", "path": "sway-core/src/ir_generation/compile.rs", "hunk": "@@ -576,6 +575,300 @@ pub(super) fn compile_entry_function(\n .map(|f| f.expect(\"entry point should never contain generics\"))\n }\n \n+#[derive(Debug, Clone)]\n+pub enum CheckDecl...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
It looks like this is never used?
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-error/src/error.rs b/sway-error/src/error.rs index 97d77fe44de..c4693cecfbc 100644 --- a/sway-error/src/error.rs +++ b/sway-error/src/error.rs @@ -9,6 +9,7 @@ use crate::parser_error::{ParseError, ParseErrorKind}; use crate::type_error::TypeError; use core::fmt; +use std::collections::BTreeSet; u...
[ "sway-error/src/error.rs" ]
[ { "comment": "It looks like this is never used?", "path": "sway-error/src/error.rs", "hunk": "@@ -501,6 +502,8 @@ pub enum CompileError {\n },\n #[error(\"This opcode takes an immediate value but none was provided.\")]\n MissingImmediate { span: Span },\n+ #[error(\"Invalid argument.\")]\...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Debug statement left in production code **High Severity** <!-- DESCRIPTION START --> A `dbg!()` macro was left in production code inside `prepare_const_generics_materialization`. This will print debug output to stderr during normal compilation whenever a const generic parameter's argument type is `None`, which po...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index b15c620e47c..2b06d55297a 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_app...
[ "sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs" ]
[ { "comment": "### Debug statement left in production code\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nA `dbg!()` macro was left in production code inside `prepare_const_generics_materialization`. This will print debug output to stderr during normal compilation whenever a const generic parameter's argume...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Unhandled `todo!()` panics in indexing compilation **Medium Severity** <!-- DESCRIPTION START --> The `compile_indexing` method uses `todo!()` for two fallback match arms: when a `TypedPointer` points to something other than an array, and when the prefix type is neither a `TypedPointer` nor a `TypedSlice`. These ...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 2169d4aa07c..79cd8c73610 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -28,9 +28,13 @@ use crate::{ types::*, PanicOccurrence, PanicOccurrences, Panickin...
[ "sway-core/src/ir_generation/function.rs" ]
[ { "comment": "### Unhandled `todo!()` panics in indexing compilation\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `compile_indexing` method uses `todo!()` for two fallback match arms: when a `TypedPointer` points to something other than an array, and when the prefix type is neither a `TypedPointer`...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
### Debug `todo!()` with backtrace replaces `unreachable!()` **High Severity** <!-- DESCRIPTION START --> The previous `unreachable!()` was replaced with `todo!("{x:?} {}", std::backtrace::Backtrace::force_capture())`. This is clearly debugging code — it captures a full backtrace at runtime (which is expensive) and u...
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/semantic_analysis/type_resolve.rs b/sway-core/src/semantic_analysis/type_resolve.rs index 317d73925b2..f760a4cfbae 100644 --- a/sway-core/src/semantic_analysis/type_resolve.rs +++ b/sway-core/src/semantic_analysis/type_resolve.rs @@ -61,7 +61,11 @@ fn resolve_length( let decl = m...
[ "sway-core/src/semantic_analysis/type_resolve.rs" ]
[ { "comment": "### Debug `todo!()` with backtrace replaces `unreachable!()`\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe previous `unreachable!()` was replaced with `todo!(\"{x:?} {}\", std::backtrace::Backtrace::force_capture())`. This is clearly debugging code — it captures a full backtrace at runti...
true
FuelLabs/sway
7,575
comment_to_fix
Attribute for checking of trivial encoding and decoding
`at_most(2)` allows zero args, e.g., having just `#[require]`. This must be between 1 and 2. ```suggestion Require => Multiplicity::between(1, 2), ```
9e8750e0f618b460b7e7c88af3b690f15ae9d12d
094041d5f9a37889918e867ae39e6addba61f3c4
diff --git a/sway-core/src/transform/attribute.rs b/sway-core/src/transform/attribute.rs index fd144d75441..1cb764ecb54 100644 --- a/sway-core/src/transform/attribute.rs +++ b/sway-core/src/transform/attribute.rs @@ -358,6 +358,7 @@ pub enum AttributeKind { AbiName, Event, Indexed, + Require, } //...
[ "sway-core/src/transform/attribute.rs" ]
[ { "comment": "`at_most(2)` allows zero args, e.g., having just `#[require]`. This must be between 1 and 2.\n```suggestion\n Require => Multiplicity::between(1, 2),\n```", "path": "sway-core/src/transform/attribute.rs", "hunk": "@@ -469,6 +472,7 @@ impl Attribute {\n AbiName => Mul...
true
FuelLabs/sway
7,626
issue_to_patch
Add comprehensive in-language tests for all storage types
## Description This PR adds in-language tests for all all storage types, except for `StorageKey` and `StorageVec`, which are added in #7614. Existing SDK harness tests that were testing the same functionality are deleted. This is aligned with the decision to migrate SDK harness tests to in-language tests and and ...
ce310eb1b5abad4a885af393559834afe7f18716
19e8fbb7f2bae5aa0733fd5c7e0b0f4be31e504a
[ "test/src/in_language_tests/test_programs/storage_bytes_contract_tests/Forc.toml", "test/src/in_language_tests/test_programs/storage_bytes_contract_tests/src/main.sw", "test/src/in_language_tests/test_programs/storage_map_contract_tests/Forc.toml", "test/src/in_language_tests/test_programs/storage_map_contrac...
[]
diff --git a/test/src/sdk-harness/test_projects/storage_string/Forc.toml b/test/src/in_language_tests/test_programs/storage_bytes_contract_tests/Forc.toml similarity index 80% rename from test/src/sdk-harness/test_projects/storage_string/Forc.toml rename to test/src/in_language_tests/test_programs/storage_bytes_contrac...
true
FuelLabs/sway
7,582
issue_to_patch
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
## Description This PR optimizes the encoding and decoding of `std::vec::Vec::<T>` when `T` is a trivially encodable and decodable type. In that case, we don't have encode each element individually, but just encode the vector's length and mem-copy its content to the `Buffer`. ## Checklist - [ ] I have linked ...
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 812d8fe0a82..2169d4aa07c 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -2056,534 +2056,7 @@ impl<'a> FnCompiler<'a> { Ok(TerminatorValue::new(buff...
[ "sway-core/src/ir_generation/function.rs", "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs", "sway-error/src/error.rs", "sway-lib-std/src/codec.sw", "sway-lib-std/src/error_signals.sw", "sway-lib-std/src/raw_slice.sw", "sway-lib-std/src/vec.sw", "test/src/e2e_vm_tests/reduce...
[ { "comment": "### Test `vec_non_trivial` incorrectly tests trivial path instead\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `vec_non_trivial` test calls `create_vec_trivial(10)` and uses `Vec<u64>`, making it an exact duplicate of `vec_trivial`. It was clearly intended to call `create_vec_non_triv...
diff --git a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core/reduced_lib.config b/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core/reduced_lib.config index 5087306b772..2edfa037c21 100644 --- a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core/reduced_lib.config +++ b/test/src/e2e_vm_tests/reduc...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
### Test `vec_non_trivial` incorrectly tests trivial path instead **Medium Severity** <!-- DESCRIPTION START --> The `vec_non_trivial` test calls `create_vec_trivial(10)` and uses `Vec<u64>`, making it an exact duplicate of `vec_trivial`. It was clearly intended to call `create_vec_non_trivial(10)` and use `Vec<u32>`...
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/src/main.sw new file mode 100644 index 00000000000..dbb392a42fa --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/...
[ "test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/src/main.sw" ]
[ { "comment": "### Test `vec_non_trivial` incorrectly tests trivial path instead\n\n**Medium Severity**\n\n<!-- DESCRIPTION START -->\nThe `vec_non_trivial` test calls `create_vec_trivial(10)` and uses `Vec<u64>`, making it an exact duplicate of `vec_trivial`. It was clearly intended to call `create_vec_non_triv...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
### Script test data incompatible with new trivial encoding format **High Severity** <!-- DESCRIPTION START --> The `script_data_new_encoding` encodes `Vec<u64>` with an element-count length prefix (`0000000000000003` = 3), but the new trivial decode path uses `raw_slice::abi_decode` which interprets the prefix as a ...
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/test.run.toml b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/test.run.toml new file mode 100644 index 00000000000..e3e7741a9ab --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/std...
[ "test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/test.run.toml" ]
[ { "comment": "### Script test data incompatible with new trivial encoding format\n\n**High Severity**\n\n<!-- DESCRIPTION START -->\nThe `script_data_new_encoding` encodes `Vec<u64>` with an element-count length prefix (`0000000000000003` = 3), but the new trivial decode path uses `raw_slice::abi_decode` which ...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
Because we currently don't support neither inline modules nor something like `#[cfg(test = true)` having test types and impls in modules bloats the module and is actually confusing 😞 I was confused at first when encountering `NonTrivial` I thought it is some actual type and not a test dummy. That's why I would propos...
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw index c0f0c94a96b..0071e496ac8 100644 --- a/sway-lib-std/src/vec.sw +++ b/sway-lib-std/src/vec.sw @@ -1,7 +1,7 @@ //! A vector type for dynamically sized arrays outside of storage. library; -use ::alloc::{alloc, realloc}; +use ::alloc::{alloc, alloc_byt...
[ "sway-lib-std/src/vec.sw" ]
[ { "comment": "Because we currently don't support neither inline modules nor something like `#[cfg(test = true)` having test types and impls in modules bloats the module and is actually confusing 😞 I was confused at first when encountering `NonTrivial` I thought it is some actual type and not a test dummy.\n\nT...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
Nitpick. The body of `vec_encode_trivial` and `vec_encode_non_trivial` is essentially the same. We can have one generic `test_vec_encode<T>(v1: T, v2: T)` here and call it in both tests.
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw index c0f0c94a96b..0071e496ac8 100644 --- a/sway-lib-std/src/vec.sw +++ b/sway-lib-std/src/vec.sw @@ -1,7 +1,7 @@ //! A vector type for dynamically sized arrays outside of storage. library; -use ::alloc::{alloc, realloc}; +use ::alloc::{alloc, alloc_byt...
[ "sway-lib-std/src/vec.sw" ]
[ { "comment": "Nitpick. The body of `vec_encode_trivial` and `vec_encode_non_trivial` is essentially the same. We can have one generic `test_vec_encode<T>(v1: T, v2: T)` here and call it in both tests.", "path": "sway-lib-std/src/vec.sw", "hunk": "@@ -933,3 +944,71 @@ where\n l.finish();\n }\...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
A corner case that IMO should be covered in tests is having a **zero-sized** `T` once trivial, once non-trivial. Maybe just a reason more than for having a once defined `test_vec_encode<T>(v1: T, v2: T)` 🤔
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw index c0f0c94a96b..0071e496ac8 100644 --- a/sway-lib-std/src/vec.sw +++ b/sway-lib-std/src/vec.sw @@ -1,7 +1,7 @@ //! A vector type for dynamically sized arrays outside of storage. library; -use ::alloc::{alloc, realloc}; +use ::alloc::{alloc, alloc_byt...
[ "sway-lib-std/src/vec.sw" ]
[ { "comment": "A corner case that IMO should be covered in tests is having a **zero-sized** `T` once trivial, once non-trivial. Maybe just a reason more than for having a once defined `test_vec_encode<T>(v1: T, v2: T)` 🤔 ", "path": "sway-lib-std/src/vec.sw", "hunk": "@@ -933,3 +944,71 @@ where\n ...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
We need to update the error message in `error.rs` as well. Proposal: Only bool, u8, u16, u32, u64, u256, b256, string arrays, string slices, and (raw_ptr, u64) can be used here.
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs index 012ceb4c038..4666c48f85b 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs +++ b/sway-core/src/semantic_analysis/a...
[ "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs" ]
[ { "comment": "We need to update the error message in `error.rs` as well.\n\nProposal:\nOnly bool, u8, u16, u32, u64, u256, b256, string arrays, string slices, and (raw_ptr, u64) can be used here.\n\n\n", "path": "sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs", "hunk": "@@ -73...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
Everywhere in the `std` we have `[_]revert(0)`, except for the very few `.._SIGNAL` constants. This is IMO one of the most problematic decisions in the current error handling, complete lack of any additional information on most of the reverts 😞 From that perspective, I am more for `999` than `0`, but breaking the p...
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-lib-std/src/raw_slice.sw b/sway-lib-std/src/raw_slice.sw index bb1f8e265b4..e56d7effda0 100644 --- a/sway-lib-std/src/raw_slice.sw +++ b/sway-lib-std/src/raw_slice.sw @@ -2,6 +2,7 @@ library; use ::ops::*; use ::raw_ptr::*; +use ::error_signals::REVERT_WITH_RAW_SLICE_LEN_ZST; /// Trait to retur...
[ "sway-lib-std/src/raw_slice.sw" ]
[ { "comment": "Everywhere in the `std` we have `[_]revert(0)`, except for the very few `.._SIGNAL` constants.\n\nThis is IMO one of the most problematic decisions in the current error handling, complete lack of any additional information on most of the reverts 😞 \n\nFrom that perspective, I am more for `999` th...
true
FuelLabs/sway
7,582
comment_to_fix
Optimize encoding and decoding of `Vec<T>` when `T` is trivial
We need to document the revert condition. ```suggestion /// /// # Reverts /// /// * When `T` is a zero-sized type. /// ```
c1600d30409941616330b0dff70fec14435da9a3
2a991efd623ecab749d2a36791ec55e3dfafeb62
diff --git a/sway-lib-std/src/raw_slice.sw b/sway-lib-std/src/raw_slice.sw index bb1f8e265b4..e56d7effda0 100644 --- a/sway-lib-std/src/raw_slice.sw +++ b/sway-lib-std/src/raw_slice.sw @@ -2,6 +2,7 @@ library; use ::ops::*; use ::raw_ptr::*; +use ::error_signals::REVERT_WITH_RAW_SLICE_LEN_ZST; /// Trait to retur...
[ "sway-lib-std/src/raw_slice.sw" ]
[ { "comment": "We need to document the revert condition.\n```suggestion\n ///\n /// # Reverts\n ///\n /// * When `T` is a zero-sized type.\n ///\n```", "path": "sway-lib-std/src/raw_slice.sw", "hunk": "", "resolving_sha": "2a991efd623ecab749d2a36791ec55e3dfafeb62", "resolving_diff"...
true
FuelLabs/sway
7,620
issue_to_patch
Fix `Vec` with ZSTs
## Description Fix a bug on `Vec` on ZST. ## Checklist - [ ] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires subs...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index b3089c62be5..812d8fe0a82 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -4068,26 +4068,88 @@ impl<'a> FnCompiler<'a> { // Compile the struct expression. ...
[ "sway-core/src/ir_generation/function.rs", "sway-ir/src/instruction.rs", "sway-ir/src/optimize/init_aggr_lowering.rs", "sway-lib-std/src/raw_ptr.sw", "test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap", "test/src/e2e_vm_tests/test_programs/should_pass/language/logging/std...
[ { "comment": "I think this is fine because this is a debug build.", "path": "test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap", "hunk": "@@ -71,12 +71,12 @@ output:\n Building test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg\n Compiling li...
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap index faafb9f67a3..e9729e9656c 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap +++ b/tes...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
I think this is fine because this is a debug build.
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap index faafb9f67a3..e9729e9656c 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap +++ b/tes...
[ "test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap" ]
[ { "comment": "I think this is fine because this is a debug build.", "path": "test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap", "hunk": "@@ -71,12 +71,12 @@ output:\n Building test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg\n Compiling li...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
Having `ref mut` here is problematic from the method's semantic point of view: - it implies that we are modifying the `val`. - it also forces callers to pass mutable variables. This is also a breaking change. The fact that `std` compiles at all after this change is because we have a bug in checking the mutability. I've...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-lib-std/src/raw_ptr.sw b/sway-lib-std/src/raw_ptr.sw index 8fc2d0cecdd..63aa2bfcdd7 100644 --- a/sway-lib-std/src/raw_ptr.sw +++ b/sway-lib-std/src/raw_ptr.sw @@ -163,19 +163,19 @@ impl raw_ptr { /// } /// ``` pub fn write<T>(self, val: T) { - if __is_reference_type::<T>() { - ...
[ "sway-lib-std/src/raw_ptr.sw" ]
[ { "comment": "Having `ref mut` here is problematic from the method's semantic point of view:\n- it implies that we are modifying the `val`.\n- it also forces callers to pass mutable variables. This is also a breaking change. The fact that `std` compiles at all after this change is because we have a bug in check...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
Because `write` is at the bottom of many calls, IMO it makes sense to have it as optimized as possible. The new implementation requires unnecessary stack allocation for copy types. IMO we should go here for the best compilation possible, while also making sure that only one branch gets compiled. It might be that this...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-lib-std/src/raw_ptr.sw b/sway-lib-std/src/raw_ptr.sw index 8fc2d0cecdd..63aa2bfcdd7 100644 --- a/sway-lib-std/src/raw_ptr.sw +++ b/sway-lib-std/src/raw_ptr.sw @@ -163,19 +163,19 @@ impl raw_ptr { /// } /// ``` pub fn write<T>(self, val: T) { - if __is_reference_type::<T>() { - ...
[ "sway-lib-std/src/raw_ptr.sw" ]
[ { "comment": "Because `write` is at the bottom of many calls, IMO it makes sense to have it as optimized as possible.\n\nThe new implementation requires unnecessary stack allocation for copy types.\n\nIMO we should go here for the best compilation possible, while also making sure that only one branch gets compi...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
What about tests for other methods? `Vec` has a large API surface and lot of methods work with memory, like, e.g. resizing the `Vec`. My thinking here is, if we want to properly support ZSTs in `Vec` we can have a check in every `Vec` method if `T` is zero-sized and provide the trivial implementation. Essentially, `Ve...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec/src/main.sw index eb80bc51725..3741f482007 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should...
[ "test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec/src/main.sw" ]
[ { "comment": "What about tests for other methods? `Vec` has a large API surface and lot of methods work with memory, like, e.g. resizing the `Vec`.\n\nMy thinking here is, if we want to properly support ZSTs in `Vec` we can have a check in every `Vec` method if `T` is zero-sized and provide the trivial implemen...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
`if __size_of::<T>() == 0 { }` must be the first check because we can have ZST reference types. E.g. if we call `write` with `[u8;0]` or `struct EmptyStruct {}` the `mcp` will still be generated. A side note, `mcp dest src $zero` is not optimized away. At first look, it looks safe to me to do it (with respect to cl...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-lib-std/src/raw_ptr.sw b/sway-lib-std/src/raw_ptr.sw index 8fc2d0cecdd..63aa2bfcdd7 100644 --- a/sway-lib-std/src/raw_ptr.sw +++ b/sway-lib-std/src/raw_ptr.sw @@ -163,19 +163,19 @@ impl raw_ptr { /// } /// ``` pub fn write<T>(self, val: T) { - if __is_reference_type::<T>() { - ...
[ "sway-lib-std/src/raw_ptr.sw" ]
[ { "comment": "`if __size_of::<T>() == 0 { }` must be the first check because we can have ZST reference types. E.g. if we call `write` with `[u8;0]` or `struct EmptyStruct {}` the `mcp` will still be generated.\n\nA side note, `mcp dest src $zero` is not optimized away. At first look, it looks safe to me to d...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
> if not, it means that all variants are unit Strictly speaking, we can still have the internal error situation here, where we don't have the variant type, but not all variants are unit. In that case we should emit ICE as it was the intention of the original code (that didn't respect the case where all variants are un...
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index b3089c62be5..812d8fe0a82 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -4068,26 +4068,88 @@ impl<'a> FnCompiler<'a> { // Compile the struct expression. ...
[ "sway-core/src/ir_generation/function.rs" ]
[ { "comment": "> if not, it means that all variants are unit\n\nStrictly speaking, we can still have the internal error situation here, where we don't have the variant type, but not all variants are unit. In that case we should emit ICE as it was the intention of the original code (that didn't respect the case w...
true
FuelLabs/sway
7,620
comment_to_fix
Fix `Vec` with ZSTs
This is safe and it will never clash with a potential `const zero_u64` declared in code, because all user defined constants will be prefixed with the module/parent name. Still, to emphasize compiler-generation and to conform to SCREAMING_CASE naming convention, proposal is to have `__ZERO_U64` here.
b0a91271a06042763b2f62a058141edcfa06cb5f
69ac773306a480b5013bc9fe53af650da8b54f04
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index b3089c62be5..812d8fe0a82 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -4068,26 +4068,88 @@ impl<'a> FnCompiler<'a> { // Compile the struct expression. ...
[ "sway-core/src/ir_generation/function.rs" ]
[ { "comment": "This is safe and it will never clash with a potential `const zero_u64` declared in code, because all user defined constants will be prefixed with the module/parent name.\n\nStill, to emphasize compiler-generation and to conform to SCREAMING_CASE naming convention, proposal is to have `__ZERO_U64` ...
true
FuelLabs/sway
7,614
issue_to_patch
`StorageVec::insert()` does not work with nested storage types E.g., having: ```Sway storage { nested_vec: StorageVec<StorageVec<u64>> = StorageVec {}, } ``` and inserting: ``` storage.nested_vec.insert(0, StorageVec {}); storage.nested_vec.insert(0, StorageVec {}); ``` will revert at runtime at the sec...
Implement dynamic storage based `StorageVec`
## Description This PR is an additional step in implementing #7560. It implements `StorageVec<V>` for dynamic storage. Additionally the PR: - adds comprehensive test coverage for `StorageVec` in the form of in-language tests. Existing SDK harness tests are deleted in favor of new in-language tests. This is align...
514ccec75cccc818254f09e0c284db2c78b2ec2a
ecc2c92ea28c187e76d47f70d6de0024c884c202
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 663f5c6d925..94c9154ad52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -523,22 +523,39 @@ jobs: run: forc test --path sway-lib-std --experimental dynamic_storage - name: Run Std Unit Tests - ['dynamic_storag...
[ ".github/workflows/ci.yml", "justfile", "sway-lib-std/src/raw_slice.sw", "sway-lib-std/src/storage/storage_api.sw", "sway-lib-std/src/storage/storage_bytes.sw", "sway-lib-std/src/storage/storage_string.sw", "sway-lib-std/src/storage/storage_vec.sw", "test/src/e2e_vm_tests/test_programs/should_pass/lan...
[ { "comment": "### Test verification uses wrong split point for expected sequence\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe expected sequence construction in `assert_insert_impl` uses `middle_index` (which is an index into the *vector* after front insertion) as a split point into `expected_values`. ...
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/array/array_repeat/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/array/array_repeat/stdout.snap index 5178a69a0b8..1fcfe35878e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/array/array_repeat/stdout.sn...
true
FuelLabs/sway
7,614
comment_to_fix
Implement dynamic storage based `StorageVec`
### Test verification uses wrong split point for expected sequence **Low Severity** <!-- DESCRIPTION START --> The expected sequence construction in `assert_insert_impl` uses `middle_index` (which is an index into the *vector* after front insertion) as a split point into `expected_values`. After the front insert, ori...
514ccec75cccc818254f09e0c284db2c78b2ec2a
ecc2c92ea28c187e76d47f70d6de0024c884c202
diff --git a/test/src/in_language_tests/test_programs/storage_vec_insert_contract_tests/src/main.sw b/test/src/in_language_tests/test_programs/storage_vec_insert_contract_tests/src/main.sw new file mode 100644 index 00000000000..d523111a552 --- /dev/null +++ b/test/src/in_language_tests/test_programs/storage_vec_insert...
[ "test/src/in_language_tests/test_programs/storage_vec_insert_contract_tests/src/main.sw" ]
[ { "comment": "### Test verification uses wrong split point for expected sequence\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe expected sequence construction in `assert_insert_impl` uses `middle_index` (which is an index into the *vector* after front insertion) as a split point into `expected_values`. ...
true
FuelLabs/sway
7,614
comment_to_fix
Implement dynamic storage based `StorageVec`
### Test script runs `forc test` on `test_types` library **Low Severity** <!-- DESCRIPTION START --> The `find` command with `-mindepth 2 -maxdepth 2` matches `test_programs/test_types/Forc.toml` alongside actual test projects. This causes the script to run `forc test` on the `test_types` utility library, which is a ...
514ccec75cccc818254f09e0c284db2c78b2ec2a
ecc2c92ea28c187e76d47f70d6de0024c884c202
diff --git a/test/src/in_language_tests/run_in_language_tests.sh b/test/src/in_language_tests/run_in_language_tests.sh new file mode 100755 index 00000000000..d09239e82e1 --- /dev/null +++ b/test/src/in_language_tests/run_in_language_tests.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Run `forc test` individually for e...
[ "test/src/in_language_tests/run_in_language_tests.sh" ]
[ { "comment": "### Test script runs `forc test` on `test_types` library\n\n**Low Severity**\n\n<!-- DESCRIPTION START -->\nThe `find` command with `-mindepth 2 -maxdepth 2` matches `test_programs/test_types/Forc.toml` alongside actual test projects. This causes the script to run `forc test` on the `test_types` u...
true