## Description
Currently update-contract-ids.sh cannot be run on any recent macOS
installation, as the system-provided grep and sed are incompatible with
the linux-specific options used. The GNU versions of these are available
through homebrew, so it would be nice to use those. Unfortunately, those
are installed with `g` prefix, so the binaries are named `gsed` and
`ggrep`. This PR changes the script to prefer these `g`-prefixed
commands, making the script work on macOS as well.
I tested this on a recent clean Ubuntu install, as well as latest macOS,
and it works on both.
## 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). N/A
- [ ] 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. N/A
- [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
- Uncomment clean git status
- allow interactive update with the `-i` flag.
## 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: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
## Description
This PR fixes a problem with `std::Bytes`, `std::Vec` and `std::String`
buffer ownership. It also fixes a problem with buffer overflow when
encoding huge types.
## Buffer Ownership
Currently, types like `Bytes`, `Vec` and `String` do not guarantee
ownership of their buffer. That means that we can very easily alias the
underlying buffer and change its mutability by simply creating a new
instance.
For example:
```sway
let some_slice = ...;
let buffer = Bytes::from(some_slice);
let mut buffer2 = buffer.clone();
// Now I can change `some_slice`
```
## Type Inference bug
I also had to fix a small problem with the type inference of method
applications. The problem is that sometimes the type check does not
return an error on the first pass, but the type is still not concrete.
For example `x.get(0) == Some(2)`, becomes `eq(x.get(0), Some(2))`.
After the first pass, `x.get(0)` is correctly inferred to be
`Option<u8>`; but `Some(2)` is only typed as `Option<Numeric>`. This
happens because the first pass starts with `TypeInfo::Unknown`. We can
use the argument types here because they may still be non-concrete types
like "Self".
What the fix is doing is that it checks if the inferred type
`is_concrete`, assuming that `Numeric` is not. This will make "Some(2)"
be type-checked again at the second pass, after monomorphization and be
correctly typed as "Option<u8>".
## IR Verification errors
This PR also improves the error message for IR verification. Now the
error is shown inside the printed IR.

## Script to update contract-ids (optional)
At `test/update-contract-ids.sh` there is a small script that
automatically updates contract ids. Unfortunately, given the indirect
nature of contract calls, it is impossible for the script to know which
contract it needs to compile. So we need to specify the path to the
contract.
We also need to pass the compiler flags, because in some cases we use
`debug` profile, and in others we use `release`.
```sway
const FUEL_COIN_CONTRACT_ID = 0x1a88d0982d216958d18378b6784614b75868a542dc05f8cc85cf3da44268c76c; // AUTO-CONTRACT-ID ../../test_contracts/test_fuel_coin_contract --release
```
In the example above, the path and flags are appended in the bash
script. I failed trying to inject commands, so I think the append is
safe.
I can remove this from the PR, if we find that this is not the solution
we want at the moment.
## 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.