Commit graph

1324 commits

Author SHA1 Message Date
João Matos
221e18b8c7
Implement Display and DisplayWithEngines for some more types (#5999)
## Description

This PR implements `Display` and `DisplayWithEngines` for some more
types to help with debugging.

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-17 08:03:56 +00:00
Daniel Frederico Lins Leite
76860b8e24
fail const eval if return_type is error (#6023)
## Description

This PR is part of https://github.com/FuelLabs/sway/issues/5727.
Fix the issue of trying to solve expressions that were typed as
`ErrorRecovery` inside `const_eval`.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-17 07:16:19 +00:00
Kaya Gökalp
0f1bdef8a4
chore: use fuels-rs v0.62.0, fuel-abi-types v0.5.0 (#6027)
## Description

Bumps:

1. fuels-rs v0.62.0
2. forc-wallet to v0.7.1
3. fuels-abi-types to v0.5.0

In the process I had to adjust forc-run to use new encoding api from the
sdk as well.
2024-05-16 18:02:41 -07:00
Igor Rončević
8c999fa252
Improve IR printing CLI in forc (#6025)
## Description

This PR:
- implements detailed control over printing of IR:
  - initial IR
- IR after choosen optimization steps, with option to print only the
steps that have actually modified the IR
  - final IR
- improves printed IRs by removing the confusing empty modules printed
for every external library dependency.
- harmonizes names and descriptions of the optimization passes. The
proposed convention is documented in the
_sway-ir/src/optimize/README.md_ file.
- harmonizes help comments of the shared compiler options (consistent
separation between option title and additional info, wording, etc.)

## Demo

```
'Print initial and final IR together with IR after each optimization step.
--ir all

'Print initial and final IR together with IR after each optimization step that has modified the IR.
--ir all modified

'Print only the final IR.
--ir final

'Print the IR after every "dce", "sroa", and "inline" optimization step.
--ir dce sroa inline

'Print the IR after every "dce", "sroa", and "inline" optimization step that has modified the IR.
--ir dce sroa inline modified
```

## Breaking Changes

### CLI

Instead of the existing `--ir` option without parameters we now have the
same CLI option but with parameters. The existing `--ir` is equivalent
to the new `--ir final`.

### Build Profile

Instead of the existing `print-ir` of type bool, we now have the same
`print-ir` build profile option with parameters. E.g.:

```
print-ir = { initial = true, final = false, modified = true, passes = ["dce", "sroa"]}
```

## Checklist

- [ ] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-17 10:42:00 +10:00
Joshua Batty
8d50370814
change to use parking_lot::RwLock for better performance (#6014)
## Description
Switching from `std::sync::RwLock` to `parking_lot::RwLock` is giving us
a 10% further performance increase.

before: `13.459551958s`
after: `12.125325542s`

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2024-05-15 07:50:12 +00:00
IGI-111
3c86abb400
Update clap and deps to latest version (#5994)
## Description

Update clap and deps to latest version

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-14 15:35:01 +04:00
Kaya Gökalp
9579dd2f77
chore: bump to v0.58.0 (#6003)
## Description
Bumps sway repo to 0.58.0.
2024-05-13 16:44:55 -07:00
Igor Rončević
8148817c02
Remove redundant IR generation of constants and unused IR main inlining (#5998)
## Description

This PR:
- removes the redundant calls to `compile_declarations` function and the
function itself. The function was used in early versions of Sway, but
the way we compile items to IR has changed: functions are compiled at
call site, and structs and enums are inlined at instantiation site. In
the end, the function was only compiling constants, but that was already
done in the dedicated `compile_constants` calls.
- removes the `inline_main` optimization which was aggressively inlining
the whole program into `main` function. This was a necessity in early
versions of Sway and is not used anymore.

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-13 16:02:15 +01:00
Igor Rončević
fa62d82d8a
Improve ASM printing CLI in forc (#5997)
## Description

This PR simplifies and gives more control ove printing the ASM. It's a
first step in harmonizing printing options for ASM and IR, where the
goal is to be able to print arbitrary optimization passes in IR.

This PR:
- replaces two existing, verbose and unintuitive to discover, ASM
printing CLI options with a single `--asm`, same as the single `--ir`
option.
- improves printed ASM by removing the confusing empty programs printed
for every external library dependency.
- harmonizes printed virtual and allocated abstract ASM to have the
same-looking comments and structure.

Additionally, the PR fixes the bug in the
`PassManager::insert_after_each` helper function, where passes were not
inserted within groups. This is a preparation step for the changes
needed for improving the `--ir` CLI option.

## Demo

```
--asm all               'Prints virtual, allocated, and final ASM.
--asm final             'Prints only the final ASM.
--asm allocated final   'Prints the allocated and the final ASM.
```

## Breaking Changes

### CLI

Instead of existing `--intermediate-asm` and `--finalized-asm` options
we now have a single `--asm` CLI option with parameters. The existing
options should be replaced:

| Current | New |
| - | - |
|`--intermediate-asm`|`--asm abstract`|
|`--finalized-asm`|`--asm final`|
|`--intermediate-asm --finalized-asm`|`--asm all`|

### Build Profile

Instead of existing `print-intermediate-asm` and `print-finalized-asm`
options we now have a single `print-asm` CLI option with parameters.
E.g.:

```
print-asm = { virtual = true, allocated = true, final = true }
```


## Checklist

- [ ] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-13 13:51:23 +01:00
IGI-111
b939c0be73
Bump to v0.57.0 (#5993) 2024-05-13 08:19:45 +01:00
Daniel Frederico Lins Leite
a7d35d3f09
Encoding v1 for Configurables (#5942)
## Description

This PR uses `AbiEncode` on configurables.  We can imagine that 

```sway
configurable {
    SOMETHING: u64 = 1
}

fn main() -> u64 {
    SOMETHING
}
```

will be desugared into

```sway
configurable {
    SOMETHING: slice = encode(1)
}

fn main() -> u64 {
    abi_decode(SOMETHING)
}
```

To allow this, now the whole `encode` function and all trait impls run
inside `const_eval`. To make this work, three new intrinsic were
implemented: `EncodeBufferEmpty`, `EncodeBufferAppend`, and
`EncodeBufferAsRawSlice`.

`EncodeBufferEmpty` creates an empty "encoding buffer", which is
composed of a pointer to the buffer, the buffer capacity, and how many
bytes were written already.

`EncodeBufferAppend` appends any primitive data types to the buffer.
This intrinsic does not mutate its argument, it returns a new "encoding
buffer". If no reallocation is needed, the pointer and the capacity stay
the same.

`EncodeBufferAsRawSlice` returns a slice with is composed of the buffer
pointer and its length (not the capacity).

### Errors

Some constant expressions cannot live inside the data section because
their encoding depends on some instance value, for example: string
slices, Vecs, Sttrings, Bytes etc... For these we now we return an error
in these cases, like

```
  error
            --> /home/xunilrj/github/sway/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/src/main.sw:33:5
             |
          31 | 
          32 |     C6: str[4] = __to_str_array("fuel"),
          33 |     C6_2: str = "fuel as str",
             |     ^^^^ This code cannot be evaluated to a configurable because its size is not always limited.
          34 |     C7: [u64; 4] = [1, 2, 3, 4],
          35 |     
             |
          ____
```

## Future TODOs

This PR adds two more tasks to
https://github.com/FuelLabs/sway/issues/5727:

- Enable sdk-harness tests that were ignore. SDK needs to update
configurable encoding.
- Correctly error when a type with custom impl for AbiEncode is used in
configurables
- avoid decoding on each use

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Igor Rončević <ironcev@hotmail.com>
2024-05-12 18:22:46 +01:00
jjcnn
5a56a58332
Name clash in star imports should result in error when the name is used (#5963)
## Description

Fixes #5940. 

This PR deals with the situation where the same name is imported by
multiple star imports, e.g.,
```
// a.sw
struct X = ...

// b.sw
struct X = ...

// main.sw
use a::*;
use b::*;
```
So far we have resolved this name clash by letting the latter import
shadow the former, which is incorrect.

The correct behavior is to allow the import without error, but to report
an error if the unqualified name (i.e., `X`) is used (qualified names
`a::X` and `b::X` are legal)`. This PR fixes this problem.

Note that if `X` is imported multiple times, but each time is bound to
the same entity (e.g., because it is imported both through
`core:;prelude` and `core::codec`), then this should not cause an error.

Note also that there is a problem with the implicit imports from the
core and std preludes, which in some cases causes the implementation to
think that a name is bound to multiple different entities, even though
the entities are actually the same. As a workaround anytime a name is
imported from either `std` or `core` when it is already imported from
`std` or `core`, the new binding replaces the old one instead of being
added as a new binding.

Unfortunately this workaround means that it is not currently possible to
redefine and use a name that exists in `std` or `core`, e.g., to create
a specialized version of `assert_eq` as is done in one of our tests. To
use such a redefinition one must use a qualified name for the entity,
which seems like an acceptable workaround. (Note that this only applies
if the redefined entity is imported using a star import - if imported
using an item import (`use a::X;`), then there is no issue).

Once #3487 is implemented this workaround should no longer be necessary.


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-05-11 21:56:32 +00:00
Kaya Gökalp
fc4007dcdd
chore: bump to fuel-core v0.26.0 (#5981)
## Description

Bumps fuel-core to v0.26.0, for some reason sway-core was failing and
needed a blanket implementation for `Vec<T: PartialEqWithEngines>`
2024-05-10 11:11:13 +01:00
Joshua Batty
e2f55b8dfd
Make ControlFlowGraph store a reference to Engines to remove clones (#5983)
## Description
Using the same performance test as in #5976 and #5978, this change gives
a further 21.33% performance improvement.

Before: Elapsed time: `14.653166459s`
After: Elapsed time: `11.527667375s`
2024-05-10 09:50:24 +01:00
Vaivaswatha N
eb43057092
Add function deduplication in debug mode, but considering metadata equality (debug info) (#5977)
Closes #5890

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-10 07:35:30 +02:00
Joshua Batty
9e51a2820d
change submodules to use im::HashMap instead of im::OrdMap (#5976)
## Description

The [`im` docs](https://docs.rs/im/latest/im/) state that the
performance of `HashMap` is similar to that found in `std` but the
`ImOrd` is between 2-3x slower than `BTreeMap`. Changing submodules from
using `im::OrdMap` to using `im::HashMap` is giving us a nice
performance win.

I tried compiling the libraries project from fluid protocol as a test,
it has 19 seperate libraries. This change gives us a 21.25% speed
increase.

Before: Elapsed time: `27.968193458s`
After:  Elapsed time: `22.02603425s`

Running the compile benchmark in LSP is showing a 29% improvement. 

Before: Elapsed time: `3.8328s`
After: Elapsed time: `2.7086s`

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-05-09 23:43:55 +01:00
Joshua Batty
76c41c80ef
Wrap BaseIdent name_override_opt & TraitName in an Arc (#5978) 2024-05-09 14:29:12 -07:00
Sophie Dankel
f8e8d356be
ci: fixing typos programmatically (#5975)
## Description

Adds a CI check for typos and fixes all* typos in code, comments, and
docs.

*found by [typos-cli](https://github.com/crate-ci/typos)

`typos` doesn't catch everything, but it seems to work better than
codespell and cargo-spellcheck (fewer false positives).

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2024-05-09 10:21:32 +10:00
IGI-111
4a63b41de1
Bump to v0.56.1 (#5974) 2024-05-08 22:26:41 +00:00
João Matos
7c926d20d2
Refactor: Split contract-specific namespace module code into its own file. (#5948)
## Description


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-06 20:35:36 +04:00
Vaivaswatha N
20b8ff062e
Fixes to accessing the data section during bytecode gen (#5927)
## Description

This PR fixes a bunch of issues we had in generating access to the data
section. It also fixes #5876.

Reverts #5918.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-06 04:20:45 +00:00
João Matos
1fd9e4772a
Cleanup duplicated data from ty::TyDecl (#5751)
## Description

This PR cleans up the `ty::TyDecl` struct by removing fields for
duplicated data that we already have access through the engines. Have
not measured the true impact of this, but should have a noticeable
performance and especially memory improvement.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-06 03:23:39 +00:00
Joshua Batty
297de57a67
Larger clippy::pedantic and code quality pass on whole repo (#5945)
## Description
There's still a ton more to do but going to open this to get merged to
avoid conflicts. We can possibly add in some of these rules into CI in a
future PR.

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2024-05-04 14:00:56 -07:00
João Matos
406702a8a7
Clean up dead code. (#5946) 2024-05-03 07:34:31 +10:00
jjcnn
722c95c00c
Eliminate alias map from lexical scope (#5931)
## Description

Fixes #5912, #5713 .

Item imports with aliases `use x::y as z` have so far been represented
using two maps:
- A synonyms map mapping `y` to the type declaration of `x::y`.
- An alias map mapping `z` to `y`.

This is confusing, since `y` is not actually bound by this import, and
unsurprisingly has lead to a bug because of a name capture (see #5713).

This PR eliminates the alias mapping, and changes the synonyms map to
map `z` to the type declaration of `x::y`.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-05-02 10:43:20 +01:00
jjcnn
2a98742bf7
Refactor: Move import name resolution to Root (#5916)
## Description

Fixes #5913 .

Name resolution for imports and top-level items in module currently
happens at the module level, in part by traversing the submodules of the
current module.

This PR moves name resolution to the root of the module structure.

This refactoring is needed to enable fixes to the following issues:
- #5713 : The resolved type declaration must be understood in the
context of the declaring module rather than in the context of the
importing module, which means that name resolution must happen across
the module structure.
- #5498 : The modules from which items are imported are currently
introduced as submodules to the importing module (in addition to their
absolute location in the module hierarchy). To remove those submodules
the name resolution algorithm needs access to the full module hierarchy,
which it can get by having access to the root of the hierarchy.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-05-01 11:13:12 +10:00
Igor Rončević
daee1c247c
Dereferencing as reassignment target (#5923)
## Description

This PR implements dereferencing in reassignment targets, as defined in
[references](https://github.com/FuelLabs/sway-rfcs/blob/ironcev/amend-references/files/0010-references.sw).
The overall effort related to references is tracked in
https://github.com/FuelLabs/sway/issues/5063.

Up to now, it was only possible to read the values references refer to.
This PR allows values to be written over `&mut` references. In other
words, any `*<expression that results in &mut>`is now an l-values and
can be used in left-hand sides (LHS) of assignments. In most of the
cases, the `<expression>` will very likely be just a reference variable,
but any expression that results in `&mut` is allowed and supported.
E.g.;

```Sway
*mut_ref_to_u64 = 42;

*if condition { &mut x } else { &mut y } = 42;

*max_mut(&mut x, &mut y) = 42;
```

Additionally, the PR:
- fixes #5736 by properly replacing decls in reassignment LHSs.
- fixes #5737 by properly substituting types in reassignment LHSs.
- fixes #5920 by properly connecting expressions in array indices to the
DCA graph.
- fixes #5922 by type-cheking the array indices in reassignment LHSs and
forcing them to be `u64`.
- improves misplaced and misleading error messages when assigning to
constants and other items (see demo below).
- improves error message when assigning to immutable variables by
pointing to variable declaration.
- improves error message when expression cannot be assigned to by
pointing to the problematic part of the expression. Since Sway is more
restrictive here then Rust, the restrictions, without being explained,
could cause confusion. That's why special attention was given to point
to the exact issue and explain what is actually supported in Sway (see
demo below).
- reduces number of expected warnings in references E2E tests that were
previously set high because of DCA issues that are fixed in the
meantime.

The PR also brings additional analysis and checks to IR optimizations.
Among other things, it explicitly points out the cases in which a
potential usage of a symbol cannot be deterministically confirmed or
denied. In this PR properly reacting for such cases is done in some
optimizations. Rolling it out fully will be done in a follow up PR
#5924. More advanced escape analysis will be done later on, as a part of
allocating values on the heap in case of referencing.

This PR implements only dereferencing in LHS. Support for referenced
elements in the element based access (without dereferencing) will be
done in a separate step as an ongoing work on implementing #5063.

Closes #5736, #5737, #5920, #5922.

## Demo

Before:
![Assignment to constant -
Before](e6b29d31-8e29-4ffa-acfe-a844ac50887b)

![Assignment to decl -
Before](ef5f025e-3dcc-4cb0-b52f-d735e2ee451e)

After:
![Assignment to constant -
After](f3dfdbd9-2123-4a96-98a7-b3c7a3f3e7f9)

![Assignment to decl -
After](ae765d61-41b2-478c-96c0-d476604deec6)

Expression cannot be assigned to:

![Expression cannot be assigned
to](384d0bb7-34a1-446a-acd5-6c8f66dc4ed5)

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-30 18:39:07 +02:00
IGI-111
b495d0df69
Bump to v0.56.0 (#5919)
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-26 05:46:45 +04:00
toofooboo
db394a362b
chore: fix some comments (#5880)
## Description


 fix some comments

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

Signed-off-by: toofooboo <cmaker@foxmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2024-04-25 22:57:30 +00:00
Daniel Frederico Lins Leite
1aec319e31
set new encoding as true by default and allow it to be disabled (#5915)
## Description

This PR sets the "new encoding" (from now on will be called "encoding
v1") as the default. We can still disable it using `no_encoding_v1`,
which switches back to "encoding v0".

Actions that needs to be done after this being merged will exist in
https://github.com/FuelLabs/sway/issues/5727

New features
  - ABI Super traits;
  - AbiEncode buffer dynamic sizing;

Bugs Fixed
- `ContractCall` intrinsic interaction effect was not set correctly;

Fixing warnings and error messages
- Better error message when core-lib is not available for
scripts/contracts/predicates;
- Better error message when main inputs/outputs are unknown or error
types;
- Better error message when main inputs/outputs do not implement
AbiEncode/AbiDecode;
- Don't warn impurity attributes on the "__entry" fn;
- Don't warn CEI on the "__entry" fn. Our CEI analysis, currently, does
not recognize `Never`. This means it does not realize it is impossible
to call two contract functions;

Test Disabled (needs to be enabled again in the future)
- should_pass/language/name_resolution_after_monomorphization
- should_pass/language/shadowing/shadowed_glob_imports
- should_pass/language/name_resolution_inside_intrinsics
- sdk-harness/external_proxy test is not working. I am assuming it is
the LDC bug that is already fixed on version 0.25. What is happening is
that the literal "double_value" has the correct length, but some random
data. Which makes the method selector fails. Only after we call LDC. The
proxy contract is working.

Test generating more warnings than before
- should_pass/dca/contract/superabi_contract_calls
What happens here is that when we implement a trait for `Contract`, we
actually generate two functions: one prefixed `__contract_entry` that is
called by the method selector; and another one normal, that can be
called freely. So, if the trait method is never called manually, it is
marked as dead.
- should_pass/dca/contract/abi_fn_params
I actually think the new warning is correct and nothing here needs to be
done.

Test with fewer warnings than before
- should_pass/dca/unused_fields
auto-impl is making all fields being used. so no dead code warnings are
being generated. We need to fix this.

Changes to std-lib
- Functions that return data about call context changed the semantic.
`first_param` and `second_param` return the value as the VM sees them.
We now have `called_method` and `called_args`. This means that we can
change the protocol later and still keep these four functions always
working and with meaningful names.
- 
- predicate_data also was updated to use encoding v1 protocol.

ICE
- increase_buffer_if_needed implementation is a little bit strange
because does not work as a method inside `Buffer`. For some reason, it
is generating an ICE. I need to create an issue so we can fix, and
improve the implementation here.
- `Buffer` used by AbiEncode needs a `push_bytes` so we can be more
efficient when encoding Bytes and others.

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2024-04-25 20:37:50 +04:00
jjcnn
55140ba8d5
Refactor: Split use synonyms into separate maps for glob and item imports (#5914)
## Description

Fixes #5911 .

So far all imported items in a module have been collected in single map,
with a flag in each value indicating whether it was the result of a
glob/star import or an item import (this distinction matters because
item imports shadow glob imports).

This PR splits the map in two: One for glob imports and one for item
imports. This simplifies name resolution, and eliminates the
`GlobImport` flag.

When another module imports all reexported items the logic is now
slightly more complex, but this will be resolved once the excessive
cloning of namespaces, modules and typed declarations are eliminated.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-24 19:04:26 +04:00
Marcos Henrich
4afe1c6b25
Fixes type inference on inlined method applications. (#5823)
## Description

We now do the return type unification before doing the second pass of
arguments type checking in method application type checking.

Doing the unification sooner fixes the problem we were having while
doing:
```
let mut bytes = Bytes::new();
bytes.push(1_u64.try_into().unwrap());
```
With the unification sooner we will unify the return of unwarp with the
type annotation of the push argument before we do the type checking of
`1_u64.try_into()`. By the time we do `1_u64.try_into()` we will already
have the type parameter `U` unified with u8.

Fixes #5802.

## Checklist

- [x] 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 substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-23 22:58:08 +01:00
Marcos Henrich
d092929664
Fixes missing error when using trait constraint. (#5882)
## Description

When using trait constraints a blanket implementation is added for the
trait constraint generic parameter.

This changes avoid the generation of other implementations from the type
parameter generic implementation.

Fixes #5873

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
2024-04-22 10:10:00 +00:00
João Matos
e8e6d3aa3a
Refactor read and write access to namespace modules. (#5868)
## Description

This PR prepares existing code that deals with (mutable) access to
namespace modules to work with an upcoming PR that introduces a module
ID for optimization purposes.

It also refactors the ABI code to pass engines around, which is
necessary for the same PR.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-19 10:25:46 +04:00
Joshua Batty
60ea55e692
chore: bump to v0.55.0 (#5872)
## Description

waiting on #5871
2024-04-18 09:47:57 +02:00
Vaivaswatha N
b94d3d70ee
Do not force inling functions that have pointer args. (#5762)
The new encoding can handle functions with pointer arguments.

So this change reverts #4899. That PR also added a test which now passes
without the forced inlining.

Also see #2819, which first introduced this hack.
2024-04-16 18:05:07 +04:00
Marcos Henrich
fc572d54ac
Improves debug build times. (#5861)
## Description

Adds DCE before running other optimizations on the backend.

Running DCE before other optimizations reduces compile time in compolabs
project from over 40 minutes to 76 seconds.

Fixes #5769

## Checklist

- [x] 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 substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-04-16 14:34:11 +04:00
Igor Rončević
c6948e2859
Fix and improve Unimplemented compile errors (#5847)
## Description

This PR:
- closes #5803 by providing the proper error message that `mut` is not
implemented in pattern matching. Support for `ref`, `mut`, and `ref mut`
in pattern matching will be done later as a part of support for
references in pattern matching.
- closes #5846 by checking if aliased type can be matched.
- provides `Diagnostic` for the `Unimplemented` error and removes the
`UnimplementedWithHelp` error.
- differentiates between unimplemented features and features that are
actually semantically not supported. Previously, `Unimplemented` error
was used for both which emitted misleading errors in `match` expressions
and trait implementations.

Closes #5803, #5846.

# Demo

Before:
![Self type of an impl block is not valid -
Before](7375b30a-70b8-4e37-b15d-7290d62d2ac1)

After:
![Self type of an impl block is not valid -
After](5c12a4cb-2a68-4583-b204-5595c9e4cef0)

Diagnostic for `Unimplemented` error:
![Matching on this type is currently not implemented -
After](db15b604-5aa9-4cf9-a608-4804a202ab4c)

## Checklist

- [x] 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 substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-15 12:10:17 +01:00
IGI-111
d90cbc8419
Bump to v0.54.0 (#5853) 2024-04-13 04:03:01 +04:00
Marcos Henrich
c34231f67d
Improves DCA warnings after divergent expressions. (#5726)
## Description

DCA warnings were missing when methods call return in some places.

Changes e2e test runner to use file checker in tests with category runs.

Fixes https://github.com/FuelLabs/sway/issues/5666

## Checklist

- [x] 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).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-04-11 14:36:39 +00:00
Joshua Batty
b30f0e83d3
chore: bump to v0.53.0 (#5831)
## Description
Bump repo to 0.53.0

waiting on #5813

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-04-11 11:15:06 +00:00
Joshua Batty
6c21a39bea
Fix critical GC <> LSP bug and enable dynamic GC configuration. (#5813) 2024-04-11 19:07:59 +10:00
Marcos Henrich
b79551a686
Fixes FQP root type not found when inside a library. (#5832)
## Description

When a fully qualified path was used inside a library using a type
within the same file the symbol would not be found.

Fixes #5826

## Checklist

- [x] 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 substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-10 23:28:47 +00:00
Marcos Henrich
4f12ac3434
Fixes compiler performance in mega_example. (#5841)
## Description

ReplaceDecls for method application was calling replace_decls twice for
FunctionDecl. This was visiting function declarations as a binary tree,
doing replace decls twice per FunctionDecl.

With these changes, we merge both decl mappings before calling
replace_decls once instead of twice.

The performance dropped from over 2min(did not wait for test to finish)
to 7 seconds in the mega example. With --experimental-new-encoding and
--release.

## Checklist

- [x] 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 substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-10 12:24:57 +01:00
Daniel Frederico Lins Leite
35c810e30b
Optimize retrieve_interface_surface_and_items_and_implemented_items_for_type (#5837)
## Description

Partially addresses https://github.com/FuelLabs/sway/issues/5781.

This reduces the problem of millions of TyFunctionDecl being created.
For more details see: https://github.com/FuelLabs/sway/pull/5782

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-10 09:06:51 +01:00
Daniel Frederico Lins Leite
89e5708402
Fix and improve errors when the entry fns cannot be generated (#5824)
## Description

This PR improves fix a problem when a type cannot be auto-impled and
improve error messages for this case.

This can be seen on `tests/types/contracts/type_inside_enum` in the Rust
SDK repo.
```
     Running `target/debug/forc build --path /home/xunilrj/github/fuels-rs/packages/fuels --experimental-new-encoding`
thread 'main' panicked at sway-ir/src/constant.rs:172:14:
Enums are aggregates.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Given that this PR also improve implementation of arrays for `AbiEncode`
and `AbiDecode`, the entry function is actually generated. But in case
of error, it will fail like:

```
error
    --> /home/xunilrj/.forc/git/checkouts/std-9be0d6062747ea7/5645f10143243e1fd64a55002cd5c09730636ece/sway-lib-core/src/codec.sw:2192:8
     |
2190 | 
2191 | pub trait AbiDecode {
2192 |     fn abi_decode(ref mut buffer: BufferReader) -> Self;
     |        ^^^^^^^^^^ No method named "abi_decode" found for type "SomeEnum".
2193 | }
     |
____

error
 --> <autogenerated>:5:61
  |
3 | 
4 |                     let args: (SomeEnum,) = decode_second_param::<(SomeEnum,)>();
5 |                     let result_arr_inside_enum: raw_slice = encode::<SomeEnum>(__contract_entry_arr_inside_enum(args.0));
  |                                                             ^^^^^^^^^^^^^^^^^^ Trait "AbiEncode" is not implemented for type "SomeEnum".
6 |                     __contract_ret(result_arr_inside_enum.ptr(), result_arr_inside_enum.len::<u8>());
7 |                 }
  |
____

error
  --> <autogenerated>:24:61
   |
22 | 
23 |                     let args: (SomeEnum,) = decode_second_param::<(SomeEnum,)>();
24 |                     let result_str_inside_enum: raw_slice = encode::<SomeEnum>(__contract_entry_str_inside_enum(args.0));
   |                                                             ^^^^^^^^^^^^^^^^^^ Trait "AbiEncode" is not implemented for type "SomeEnum".
25 |                     __contract_ret(result_str_inside_enum.ptr(), result_str_inside_enum.len::<u8>());
26 |                 }
   |
____

error: Could not generate the entry method because one of the arguments does not implement AbiEncode/AbiDecode
____

  Aborting due to 4 errors.
Error: Failed to compile type_inside_enum
````


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2024-04-09 14:24:12 +01:00
Daniel Frederico Lins Leite
80f3fd3ab3
change ConcurrentSlab to use Vec (#5838)
## Description

Partially addresses https://github.com/FuelLabs/sway/issues/5781.

This reduces the time spent retrieving items in slabs.
For more details see: https://github.com/FuelLabs/sway/pull/5782

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-09 02:30:04 +01:00
Daniel Frederico Lins Leite
187146bdc2
Cache in front of check_if_trait_constraints_are_satisfied_for_type (#5827)
## Description

Partially fixes https://github.com/FuelLabs/sway/issues/5781.

This reduces the problem of millions of `TypeInfo`s being created.
For more details see: https://github.com/FuelLabs/sway/pull/5782

## 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 requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-05 10:52:45 +01:00
João Matos
2eb6f2a40d
Refactor trait map and module symbol resolution code to allow usage for parsed declarations (#5810)
## Description

This PR unifies the codepaths in trait map and name resolution code so
they can work for both parsed and typed declarations.
It does this by introducing wrapper types for the output of resolving of
names.

This is an intermediate step to being able to use this code on the new
symbol resolving pass.

While this adds a little bit of minor bloat to the code, I think it's an
acceptable further step to be able to do re-use the code in steps before
type-checking.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-04-04 09:08:46 +11:00
Kaya Gökalp
c1ea517f05
chore: bump to v0.52.1 (#5822)
## Description

Bump repo to 0.52.1
2024-04-03 12:57:19 +04:00