## Description
This PR mainly refactors existing code around type checking and
processing of functions.
[Split type checking and namespace insertion for parameters and type
parameters](327deace24)
[Split processing of functions in two
phases.](e3cf148f3f)
I've split this up from the rest of the PR for fixing impl methods
calling to make it easier to review (also made it easier for me to find
and fix some regressions).
I also threw in another round of clippy fixes that my Rust toolchain was
complaining about.
## 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.
## Description
This PR refactors the `parse_project` method to return a result instead
of writing to internal types in place. This helps to seperate the
parsing and writing logic into seperate phases, useful for future work
where we execute parsing on seperate threads.
I've also tried to clean up the `Session` interface at the same time.
## Description
This PR is part of https://github.com/FuelLabs/sway/pull/4794 and
implements more operators for u256:
- [x] sub
- [x] mul
- [x] div
- [x] comparisions
- [x] mod
## 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: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
## Description
closes#3439.
This PR adds `--args` flag and encoding capabilities to `forc-run` so
that users can provide inputs to main function of the script they are
running.
## Description
This PR is part of https://github.com/FuelLabs/sway/pull/4794. It
implements support for u256 add operators.
The IR generated is a vanilla `add` operator as any other integer.
```rust
script {
entry fn main() -> u256, !1 {
entry():
v0 = const u256 0x0000000000000000000000000000000000000000000000000000000000000001, !2
v1 = const u256 0x0000000000000000000000000000000000000000000000000000000000000002, !3
v2 = call add_0(v0, v1), !4
ret u256 v2
}
}
```
This will then be transformed by `miscdemotion` pass to something like:
```rust
script {
entry fn main() -> u256 {
local u256 __wide_lhs
local mut u256 __wide_result
local u256 __wide_rhs
entry():
v0 = get_local ptr u256, __wide_lhs, !0
v1 = const u256 0x0000000000000000000000000000000000000000000000000000000000000001, !0
store v1 to v0, !0
v2 = get_local ptr u256, __wide_rhs, !0
v3 = const u256 0x0000000000000000000000000000000000000000000000000000000000000002, !0
store v3 to v2, !0
v4 = get_local ptr u256, __wide_result, !0
wide add v0, v2 to v4, !0
v5 = load v4, !0
ret u256 v5
}
}
```
Mind the `wide add` here. It is a Fuel specific operation, giving space
to other targets to implement this differently.
## 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.
This reverts the inliner change that was done in #4823.
Without this, when sharing stack data across contract boundaries, we end
up with an illegal access.
---------
Co-authored-by: IGI-111 <igi-111@protonmail.com>
## Description
When a single method uses multiple trait implementation errors are
thrown by the compiler similar issue occurs when a method requires a
trait implementation and then calls another method that requires another
implementation of the same trait.
This PR fixes both issues by filtering traits to be replaced by the
arguments type used and trait method self type, and by gathering decl
mapping of nested methods.
Fixes#4852
## 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.
## Description
A new `Diagnostic` type is introduced for detail description of compile
errors and warnings. The change is backward compatible. The existing
`CompileWarning`s and `CompileError`s will continue render as they had
before.
The `Diagnostic` is formed out of a:
- _Level_: Error or Warning.
- _Code_: Unique error or warning code. Placeholder for future. Not used
at the moment.
- _Reason_: Short description of the diagnostic, not related to a
specific error/warning. Answers the question "Why is this an
error/warning?" E.g., Because - "Constants cannot be shadowed".
- _Issue_: Short description of the concrete case that the compiler has
found. E.g., "Variable "X" shadows imported constant with the same name"
- _Hints_: Detailed description of the diagnostic placed in the source
code.
- _Help_: Additional friendly information that helps understanding and
solving the issue, but which is not related to a place in code.

The `Diagnostic`s are defined imperatively in code right now, pretty
much the sam way we do `CompilWarning`s at the moment. Development of a
proc-macro that should make de definitions declarative is out of scope
of #21.
## Known Limitations
The `annotate-snippets` library has a bug and a missing functionality
for which I opened issues:
- Wrong display of line numbers when using folding of lines of code.
This issue is fixed but there is no patch release provided:
https://github.com/rust-lang/annotate-snippets-rs/issues/52#issuecomment-1657829040
- No possibility to remove the "note:" prefix as shown on the image
above: https://github.com/rust-lang/annotate-snippets-rs/issues/59
These two issues are not blocking. Proposal is to wait for the official
support in the library, or contribute or in the worst case make a
workaround in our code.
## Demo (Before and After)
### Errors


### Warnings


Closes#21
## 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.
- [ ] 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.
## Description
This changes addresses the issues introduced in #4878
The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros
are introduced.
All instances of introducing `ErrorEmitted` as a literal value have now
been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to be
moved to `sway-types` to avoid circular dependencies introduced by this
change.
This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.
Fixes#4885Fixes#4886
## 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.
## Description
This PR just bubbles up any errors to be logged in the server module
rather that in the `did_change` `did_open` or `did_save` methods. Also
made the resync temp folder with workspace logic it's own method on
`sync`.
## Description
This PR is part of https://github.com/FuelLabs/sway/pull/4794. It
implements the bare minimum to support `u256` constants across the
stack.
They are represented in sway in hex literals with `u256` suffixes. Hex
without suffix will still be `b256`, for backward compatibility until we
implement `u256` completely. Then we can decide what to do.
There are multiple places in the code that will fail if the literal does
not fit in u64. This will be fixed later in a specific PR for big u256.
Some places have temporary `unwrap()`, that will be removed later. I can
try to remove them now, if necessary.
I am leaving all documentation updates for when everything is
implemented.
## 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: Anton Trunov <anton.a.trunov@gmail.com>
## Description
Change error handling to use `Handler` instead of the macro based
`CompileResult`.
Fix#2734
## 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.
## Description
Closes https://github.com/FuelLabs/sway/issues/4728
Moves the on_enter capabilities to a custom LSP method that simply
returns the edits to the client, rather than directly applying the edits
as part of did_change.
With this approach, there is still some lag if you hit enter many times,
but it seems to be working better than before.
## Checklist
- [x] 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).
- [ ] 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.
## Description
avoids the extra `String` alloc from `to_string()`.
Closes#2225
## 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).
- [ ] 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.
## Description
This PR removes unused keys in sway reference so that warnings do not
appear while searching for std after creating a new project with `forc
init`.
Closes#4709
Co-authored-by: Kaya Gökalp <kaya.gokalp@fuel.sh>
## Description
In Rust, when implementing traits the type `Self` is used instead of the
concrete type. This provides a more flexible and generic API design and
it promotes code reusability and simplifies the creation of fluent
interfaces. The same has now been done for Sway.
## 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).
- [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: bitzoic <bitzoic.eth@gmail.com>
## Description
Temporarily removing the `publish_diagnostics_dead_code_warning` test so
it unblocks our CI until I can work out how to fix it. See #4855
Updates fuel-core, fuel-vm, and other fuel-* and fuels-rs dependencies
to versions corresponding to fuel-core 0.19 release.
---------
Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
This PR clears up usage of terms "ABI" (our actual ABI) and "JSON ABI"
(the JSON representation of our ABI).
What we really actually have here is the "Rust ABI" but we can drop the
"Rust" and just call it "ABI".
Other ABIs would be the "TypeScript ABI" generated by fuels-ts, and the
"GraphQL ABI" I'm planning to work on.
## Description
closes#4754.
If the default path does not contain any wallet, forc-deploy
automatically suggests creating a new one via forc-wallet:
```console
Could not find a wallet at "/Users/kayagokalp/.fuel/wallets/.wallet", would you like to create a new one? [y/N]: y
Please enter a password to encrypt this private key:
Please confirm your password:
Wallet created successfully.
```
At this step a new window opens with your mnemonic just like
forc-wallet's new flow. User pres enter:
```console
Please provide the password of your encrypted wallet vault at "/Users/kayagokalp/.fuel/wallets/.wallet":
Do you accept to sign this transaction with fuel13pudgkhq9pmsj3s2nwxmsmydqnau3lcpn5m70jrg5mrw0dlc3r8qz6pjdk? [y/N]: y
```
User is asked for their password again, to prevent this I need to cut
another release to forc-wallet which is currently blocked. So I will fix
that in a follow-up PR.
Fixes#4841
## 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] 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.
## Description
This PR replaces collecting the dummy spans for the module kind token
with the span of the module kind.
These were introduced in #4232. This was causing an issue in the
language server where we were unable to debug parsed tokens as warnings
if the span was all 0's.
closes#4809
This was required previously, but after the IR refactoring (#4336), this
is no longer required, and actually worsens things.
Fixes#4747. For the two tests mentioned there, (both based on
https://github.com/hashcloak/fuel-crypto/) the compile time now comes
down from
1. 30m -> 16s
2. 180m -> 31s
Also fixes two bugs uncovered:
1. Bug in DCE - Fixes#4763.
(1b512b87d2)
2. Bug in interaction b/w asm gen and reg alloc spiller
(7a404967e7).
---------
Co-authored-by: IGI-111 <igi-111@protonmail.com>
## Description
This does two things.
1. Integer types no longer automatically cast to each other. Methods
such as `as_u64` and `try_as_u8` have been introduced to require the
user to explicit the cast.
Warnings about casts losing precision have been removed as they are no
longer possible.
2. Numeric literals (such as `32` without further qualifications) no
longer immediately decay to a `u64` and we instead attempt to type them
as `TypeInfo::Numeric` as far as possible to allow their usage with any
integer type.
Numeric intrinsics unify arguments with the numeric type to enforce
their constraints.
Numeric values are forced to decay to `u64` when resolving methods or
traits.
This change is a prerequisite to move our representation of
sub-byte-sized values to a different memory representation, as numeric
types need to be distinct if we are ever to treat them differently.
Fixes#3470
## 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: Joshua Batty <joshpbatty@gmail.com>
Fixes#4839
## 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).
- [ ] 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.
## Description
The issue this commit solves is the method not found error thrown when
we try to use generic traits.
This issue was fixed by calling `insert_trait_implementation_for_type`
while resolving
tuples and arrays, we also call `insert_trait_implementation_for_type`
as
a fail-safe when a method is not found.
Fixes#4806
Unblocks #4701
## 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: Anton Trunov <anton.a.trunov@gmail.com>
## Description
Unused dependency check is failing as nightly version that we use for
that step is too old for fuels-program v0.44 dependency which is being
added in a separate PR. (failing PR: #4771)
## Description
It was noted that in the case of a breaking change to the std-lib, the
external Ownership library would need to be updated, which depended on
the std-lib creating a circular dependency.
The external library has been removed from the example and a skeleton of
its implementation has been added with a link to the actual
implementation.
## 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: bitzoic <bitzoic.eth@gmail.com>
## Description
- Introduce three distinguished new error messages on const shadowing as
defined in #4587:
- Variables shadowing constants.
- Constants shadowing variables.
- Constants shadowing constants, _item-style_ and _sequentially_.
- _Item-style_ and _sequential shadowing_ are added as an explicit
concept to the `TypeCheckContext`. This follows the same pattern that we
have in passing _ABI mode_ and _disallow functions_ contextual
information. Basically, the parts of the semantic analysis lower in the
chain need contextual information available and deducible in the upper
parts of the chain. In this case, the deduction is simple - as soon as
we are within a function body, we apply _sequential shadowing_. (Note
that this simple approach will not work if we ever introduce types local
to functions. But this is not an issues. In that case we will need to
redefine the const shadowing within functions in general, and also by
that time I assume we will have the graph collections which will allow
us different approach :-))
- Clean up of redundant error messages as defined in #4799.
Closes#4587, #4799
## 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.
- [ ] 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.
## Description
We will be fixing #4709, but the one thing more important than fixing it
might be ensuring that it does not happen again. Until we have the
bandwidth to introduce nice CLI testing suite I am adding myself as code
owner to forc-pkg. Since forc-pkg lives between the compiler and forc,
it is seeing lots of traffic and I will try to make sure nothing changes
in terms of user experience during those changes. Feel free to close
this, if you feel like we might have a better way of ensuring this
before we got the CLI testing suite ready.
## Description
The Sway Book's ownership example and documentation is outdated and does
not include the ownership library. It now links to the SRC-5 Ownership
standard, ownership library, and includes additional examples.
## 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: bitzoic <bitzoic.eth@gmail.com>
Co-authored-by: SwayStar123 <46050679+SwayStar123@users.noreply.github.com>
This used to house storagekey, but that since has been moved to storage
## Description
## 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).
- [ ] 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.
## Description
Switch the compiler to use relative jumps instead of absolute jumps.
1. The function `relocate_control_flow` is now removed. It used to move
basic blocks around in case absolute addresses crossed the easily
addressable boundary. The code movement can then avoid having to load
the address to a register and using indirect jumps. This is unlikely to
happen with relative jumps. But if it does, the existing algorithm
wouldn't work anyway. So we can add a new one when required later.
2. In the case of function call jumps, we use `$pc` to save the return
address for the callee. This is a bit inefficient as it involves 3 extra
computations: `$$reta = ($pc - $is) / 4 + offset_to_return_point`. We
could change this to the following: Since we already have a common
return point for every function, compute the relative offset from that
point to the callee return point statically and use that. We don't have
the infrastructure to do that right now, but it shouldn't be too
difficult an extension.
Fixes#4443
## Description
The storage tests in the language server were removed in #4464. That PR
also removed the ability for the language server to access the `storage`
token and assign correct type definition to storage fields. This PR adds
all that functionality back in.
closes#4641closes#4482
## Description
Closes https://github.com/FuelLabs/sway/issues/4276
Screenshots:




## Checklist
- [x] 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).
- [ ] 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>
## Description
- Changes `disable_panic_on_overflow()` function to return the flags set
prior to calling the function
- Adds a `set_flags` function that simply sets the given value to the
flag register
- Changed u64 `overflowing_add` and `overflowing_mul` to use the new
functions
- Adds equivalent functions for unsafe-math flag aswell
- Additional documentation for all functions in the library
closes#4355
## 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.
- [ ] 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: Vaivaswatha Nagaraj <vaivaswatha.nagaraj@fuel.sh>
The `From` trait already lets one to decompose a `u256` into four 64-bit
words. Also, there is no `compose` for `u256` (unlike `b256`, which has
both at the moment).
## Description
## 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).
- [ ] 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.
close#1491
We add ABI methods to the namespace (this is going to be useful for the
super-ABI feature) and filter out same contract method calls during
method application typechecking, instead of not adding ABI methods to
the namespace and providing a bit confusing error message like `No
method named "method1" found for type "contract".`
## 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] 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.
## Description
Closes https://github.com/FuelLabs/sway/issues/4708.
This PR does NOT change the IR generation for expressions. Instead, it
implements constant folding for unary and binary operators. The idea is
that IR generation will be kept simple and stable, and all optimizations
are pushed onto the opt passes.
To better test this, this PR also changes some implementation details on
IR generation tests:
1 - `filecheck` directives are now collected and tested in groups. This
allows a new "::check-ir-optimized::", that can be configured with the
passes you want to test, or just fallback to "o1".
2 - `filechecker` explanations are now pretty-printed, and can be
printed when `verbose=true`. This allows the test to be checked more
easily.


`breaking` label because of this change:
https://github.com/FuelLabs/sway/pull/4780/files#diff-b40fc3999876b0ff447de112b508250c7d0e7993f9023db29ddce8590d9b2286L5
## 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: Anton Trunov <anton.a.trunov@gmail.com>