Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce __eq intrinsic #2100

Merged
merged 16 commits into from
Jun 29, 2022
Merged

Introduce __eq intrinsic #2100

merged 16 commits into from
Jun 29, 2022

Conversation

vaivaswatha
Copy link
Contributor

@vaivaswatha vaivaswatha commented Jun 24, 2022

This PR introduces an intrinsic __eq<T> (currently T is constrained to integers and bool) that can replace (as shown by the changes in ops.sw) assembly definitions of eq for these types.

edit:

  1. The intrinsic is lowered to Instruction::Cmp in the IR.
  2. The existing intrinsic framework is refactored to normalise how we represent all intrinsics.

#855

@vaivaswatha vaivaswatha added compiler General compiler. Should eventually become more specific as the issue is triaged lib: std Standard library lib: core Core library labels Jun 24, 2022
@vaivaswatha vaivaswatha self-assigned this Jun 24, 2022
@vaivaswatha vaivaswatha marked this pull request as ready for review June 25, 2022 04:11
@vaivaswatha vaivaswatha requested a review from otrho as a code owner June 25, 2022 04:11
@vaivaswatha vaivaswatha requested a review from a team June 25, 2022 04:12
@Braqzen
Copy link
Contributor

Braqzen commented Jun 26, 2022

I've not looked at the code but I have noticed that there is an issue linked in the description.
If this PR is meant to close the issue then you can use one of a few special keywords that github provides in order to automatically close that issue when this PR is merged in (so that you do not have to close it yourself). You can find more info here.

@otrho
Copy link
Contributor

otrho commented Jun 27, 2022

The IR already as a cmp eq instruction which I'd hope could be used.

https://github.com/FuelLabs/sway/blob/master/sway-ir/src/instruction.rs#L34-L35
https://github.com/FuelLabs/sway/blob/master/sway-ir/src/instruction.rs#L110-L114

If it's not quite functional enough then it should be made so.

Before we get to IR the compiler needs to confirm that the types of each argument are only the builtin types and not structs or other custom types. And then for reference types like string or b256 they should use different IR, or potentially use a MEQ/memcmp intrinsic instead.

Creating ASM blocks in IRgen isn't really where we want to go, sorry.

@vaivaswatha
Copy link
Contributor Author

vaivaswatha commented Jun 27, 2022

The IR already as a cmp eq instruction which I'd hope could be used.
If it's not quite functional enough then it should be made so.

Makes sense. I'll look at using this and get back.

Before we get to IR the compiler needs to confirm that the types of each argument

I'm already doing this, more or less.

And then for reference types like string or b256 they should use different IR, or potentially use a MEQ/memcmp intrinsic instead.

Okay. I'm not handling this right now right now though.

Creating ASM blocks in IRgen isn't really where we want to go, sorry.

I understand this. That's why I pointed out the two options we have.

@vaivaswatha
Copy link
Contributor Author

I've not looked at the code but I have noticed that there is an issue linked in the description. If this PR is meant to close the issue then you can use one of a few special keywords that github provides in order to automatically close that issue when this PR is merged in (so that you do not have to close it yourself). You can find more info here.

Thank you. This PR isn't meant to close the issue, it only implements it partially.

@otrho
Copy link
Contributor

otrho commented Jun 27, 2022

Creating ASM blocks in IRgen isn't really where we want to go, sorry.

I understand this. That's why I pointed out the two options we have.

OK, cool. Hopefully cmp will work well enough. The IR needs a bunch of work still -- it doesn't do pointers properly IMO (or to my satisfaction, I guess) which makes by-reference semantics a bit ambiguous, like comparing larger types. So if it's not yet manageable it wouldn't be the end of the work to allow cmp eq to compare by-ref types for now (and do the correct magic in ASMgen) and we can fix it for pointers later.

@vaivaswatha vaivaswatha marked this pull request as draft June 27, 2022 06:10
@vaivaswatha vaivaswatha marked this pull request as ready for review June 27, 2022 12:12
Copy link
Contributor

@sezna sezna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just leaving some comments. W.R.T. my statement about using enums for extra type safety on the intrinsic arguments -- I realize that'd make iterating over the arguments harder, so if you want to do that, you may have to add an .arguments() iterator method to abstract over the varying types in the enum variants.
here's what I mean.

Do you think that the extra type safety would be worth it?

graph: &mut ControlFlowGraph,
leaves: &[NodeIndex],
exit_node: Option<NodeIndex>,
tree_type: &TreeType,
) -> Result<Vec<NodeIndex>, CompileError> {
let result = match kind {
TypedIntrinsicFunctionKind::SizeOfVal { exp } => connect_expression(
let node = graph.add_node(format!("{}", kind).into());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let node = graph.add_node(format!("{}", kind).into());
let node = graph.add_node(kind.to_string());

TypedIntrinsicFunctionKind::SizeOfVal { exp } => {
Intrinsic::SizeOfVal => {
// We index the array with confidence that the type-checker did its job.
let exp = arguments[0].clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you specify what you mean by "the type checker did its job"? The phrase "did its job" doesn't convey exactly what we are assuming here.

Comment on lines +370 to +371
let lhs = arguments[0].clone();
let rhs = arguments[1].clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we could do is codify the arguments into the enum itself, so we don't have a panic risk here.

e.g.

enum Intrinsic {
  Eq { lhs: TypedExpression, rhs: TypedExpression },
  SizeOf { type_argument: TypeInfo } 
}

etc...

I'm just suggesting this, but I wouldn't block this PR on it, as it could be a more major refactor. It would give us type safety here, though.

Comment on lines 58 to 66
self.type_arguments.iter().fold(&mut result, |accum, targ| {
accum.append(&mut targ.type_id.check_for_unresolved_types());
accum
});
self.arguments.iter().fold(&mut result, |accum, texpr| {
accum.append(&mut texpr.check_for_unresolved_types());
accum
});
result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a flat map would be a bit cleaner? No biggie either way

        self.type_arguments.iter().flat_map(|targ| {
             targ.type_id.check_for_unresolved_types())
         })
        .chain(self.arguments.iter()
          .flat_map(
            UnresolvedTypeCheck::check_for_unresolved_types
          )
         );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(didn't test that code, just writing in github)

eq r3 r1 r2;
r3: bool
}
__eq(self, other)
}
}

impl Eq for u8 {
fn eq(self, other: Self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, looks clean

@sezna
Copy link
Contributor

sezna commented Jun 27, 2022

Ah I see this commit:

@vaivaswatha
Refactor intrinsics to all have arg and type arg vectors

I see you've already had the same thoughts. Do you find it more ergonomic?

@vaivaswatha
Copy link
Contributor Author

Ah I see this commit:

@vaivaswatha
Refactor intrinsics to all have arg and type arg vectors

I see you've already had the same thoughts. Do you find it more ergonomic?

@otrho suggested that we represent intrinsics in a uniform way, for example during parsing, and later do the checks (number and type of arguments and type arguments) later on. So that motivated me to have this current representation. The idea is that when we have more intrinsics, we can put such information (number of args, type args etc) in a table and validate it with just one piece of code for all intrinsics (I'm sure we'll need exceptions, but in general it should work).

Expression::IntrinsicFunction {
kind: IntrinsicFunctionKind::SizeOfVal { exp },
#[allow(clippy::unnecessary_unwrap)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird, why is clippy complaining? intrinsic is an Option yeah?

@@ -0,0 +1,4 @@
category = "fail"

# check: $()Unsupported argument type to eq.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error should probably say __eq to avoid confusion.

Comment on lines 5 to 14
fn main() -> u64 {

assert(true == true);
assert(true != false);

assert(__eq(1, 22) == (1 == 22));
assert(__eq(1, 1) == (1 == 1));

2
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be a bit more thorough here please? We need more testing in general I think:

  • This is only testing __eq so the test name should probably be should_pass/language/eq_intrinsic.
  • Confirm that we can pass all the built-in types to __eq without type error.
  • Confirm (in a should_fail) that you can't pass custom types (structs, enums) or all by-ref types (tuples, strings, B256, etc).
  • Now that intrinsics are generalised, does the parser always parse __xxx calls as intrinsic calls? What happens if you try a ___xxx() call for an unknown intrinsic? I think we already check for this so there might be an existing E2E test, but please check that we get a coherent error message.
  • We should have an IR test (under sway-core/tests), just a small one confirming __eq generates cmp eq and not a call.

We should also document these somewhere as we add them. I'm not sure if they belong in the book... maybe not as they're only meant to be used by library devs. @sezna @mohammadfawaz Ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed all these comments, except for

What happens if you try a ___xxx() call for an unknown intrinsic?

There already are tests that address this, such as double_underscore_fn.

We should also document these somewhere as we add them.

I'll wait for @sezna @mohammadfawaz to respond.

Copy link
Contributor

@mohammadfawaz mohammadfawaz Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref: #855 (comment) as a starting point.

More generally, I've suggested in the past the idea of introducing a "Sway Reference" book that is similar to the "Rust Reference" which would include the language spec (we don't have sway.pest anymore so we don't have that in any form) as well as all the language features that are not necessarily useful for end users but only for library authors. This is a big undertaking but probably worth investing the time into. It may even include some compiler internals such as how monomorphization works for example.

Copy link
Contributor

@otrho otrho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the generalisation of intrinsics here, good stuff. We might need to refine the data driven approach to type checking, control flow/dead code analysis for them, I think there are some (OK) assumptions being made now which may not always hold in the future.

But it needs a bit more testing please.

otrho
otrho previously approved these changes Jun 28, 2022
@otrho otrho requested a review from a team June 28, 2022 08:06
@vaivaswatha vaivaswatha enabled auto-merge (squash) June 28, 2022 15:08
Copy link
Contributor

@sezna sezna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is good with @otrho, it is good with me. I think a good next item would be a more wholistic intrinsic design doc: #855 (comment)

@vaivaswatha vaivaswatha merged commit 753639c into master Jun 29, 2022
@vaivaswatha vaivaswatha deleted the vaivaswatha/intrinsic_eq branch June 29, 2022 16:04
SwayStar123 added a commit that referenced this pull request Jun 30, 2022
* Remove extra "the" (#2042)

looks like an extra "the" got into this comment

* Run `cargo update`. (#2045)

* sway-fmt-v2 adds program type to the output (#1997)

* Fix couple of bugs in handling returns in if blocks (#2029)

* Config driven E2E testing. (#2003)

Completely refactor E2E tests to be config driven.

Rather than specifying which tests are to be run and how, we now can
describe each test with a TOML file.

* Handle enums and their impls for item imports (#2034)

* Add `Identity` type to Sway Book (#2041)

* Add Identity type to Sway Book

* Move Identity code to examples directory

* Add Forc.lock to gitignore

* Update docs/src/basics/blockchain_types.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Typo

* Ran forc fmt

* Update Cargo.toml

* Update examples/identity/src/main.sw

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Delete Cargo.toml

* Update Identity docs to use anchor

* Fix CI

* Add path to std in Forc.toml and update Forc.lock std source

* Run forc fmt again

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Improve struct patterns with new warnings and rest pattern support. (#2032)

* Improve struct patterns with new warnings and rest pattern support.

This commit improves a couple aspects of handling of struct patterns.

First of all, it adds semantic checking (with a new warning) when
patterns are missing usage of all fields:

```
error
  --> src/main.sw:15:9
   |
13 |
14 |     let z = match p {
15 |         Point { x } => { x },
   |         ^^^^^^^^^^^ Pattern does not mention field: y
16 |     };
   |
____
```

Then it adds support for rest pattern, "..", which can be used as the
last token in a pattern to not have to specify all the struct fields.

The semantic AST model was updated to support modeling this pattern,
and further type checking was added to the code.

There is also a new warning for when the rest pattern doesn't appear as
the last location, or when it appears multiple times:

```
error
  --> src/main.sw:17:20
   |
15 |
16 |     let z = match p {
17 |         Point { x, .., .. } => { x },
|                    ^^ Unexpected rest token, must be at the end of
pattern.
18 |     };
   |
____
```

And lastly, tests were added to cover the changes and new functionality.

Closes #1568.

* Do not use an underscored identifier.

* Add some more pattern matching tests.

* Port to new config-driven tests.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Add the concept of semantic similarity to the type system (#1958)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Some updates to the known issues section (#2060)

Updates to the known issues section

* Constants formatting for sway-fmt-v2 (#2021)

* Update the check for unresolved types. (#2057)

* Update the check for unresolved types.

* clippy

* Remove calls to log.

* fmt

* Remove unused file.

* Make `resolve_type_with_self` and `resolve_type_without_self` take `TypeId`'s instead of `TypeInfo`'s (#1982)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Bump non-transitive `dashmap` to v5.3.4. (#2062)

Bump explicit `dashmap` to v5.3.4.

* comby-rust (#2065)

* comby-rust

* Fix clippy warning

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Adds `attribute` handling to `sway-fmt-v2` (#2061)

* wip

* add unit test

* update tests

* updated unimplemented cases to return span

* test now passes incorrectly

* update AttributeDecl::format()

* update test comment

* add close paren

* update Annotated for consistency

* chng return type for Annotated

* remove test and add todos

* Introduce a type check `Context`. Replaces `TypeCheckArguments`. (#2004)

* Introduce a type check `Context`. Replaces `TypeCheckArguments`.

* Add missing unknown type annotation. Clean up some formatting.

Also adds some resetting of the help text and type annotation (to
unknown) in many cases to better match the original behaviour. It's
difficult to tell which locations these values were originally used as
placeholders, and which locations they're a necessity for correctness.
This at least appears to fix an issue with expression return type
inference.

* Rename semantic_analysis::Context to TypeCheckContext

* Improve field doc comments for help_text, self_type

* Add doc comment to mode field in TypeCheckContext

* Construct TypeCheckContext at Program level, not module level.

This should help to clarify how we can pass other type check context
(like the declaration and type engines once they're added) through to
the submodules. Previously, this was a little unclear as the
`TypeCheckContext` was only constructed at the module level.

* Add missing namespace field doc comment to TypeCheckContext

* Fix TypeCheckContext constructor in IR test

* Add `forc check` command (#2026)

* wip

* moving back to PC computer

* adding check function to forc pkg

* have ast returning from forc pkg

* can now successfully parse all sway examples

* fmt

* added forc check

* tidy up lsp tests

* add forc check command

* forc ops doesnt need to be public

* tidy up lsp tests

* remove non relevant code

* rebase on master

* add Cargo.lock file

* add forc check to mdbook

* Small fixes to the `storage_map` example (#2079)

Small fix to storage_map example

* Move `TypeArgument`, `TypeParameter`, and `TraitConstraints` to be conceptually inside of the type engine (#2074)

Move the stuff.

* Ensure lock is applied when `BuildPlan` validation would require changes (#2090)

Ensure lock is applied if BuildPlan validation requires changes

While reviewing #2085, I noticed that some recent additions to
`BuildPlan` validation could result in some changes to the build plan
(and in turn, rewriting the lock file) even in the case that `--locked`
was specified.

This moves the `--locked` check to the moment before writing the new
lock file. This ensures all potential changes that would be required of
the `BuildPlan` are caught. It also allows us to provide a "Cause" for
*why* the lock file would need updating when `--locked` is passed to
prevent it.

Closes #2084
Closes #2085

* Add conceptual distinction between replacing `TypeInfo::Self` and monomorphization (#2017)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Add `abi` handling to `sway-fmt-v2` (#2044)

* Refactor `forc_pkg::BuildConfig` -> `BuildProfile`, fix CLI arg handling (#2094)

Previously, if any of the `print` args were set, the rest of the
selected build profile was ignored. This changes the behaviour so that
the command line arguments only override their associated build profile
fields.

Also renames `BuildConfig` to `BuildProfile` and moves it from
`forc_pkg::pkg` to `forc_pkg::manifest` along with the rest of the
serializable manifest types.

* Update all the E2E should_fail tests to verify their output. (#2082)

Using the `FileCheck` crate it can now pattern match against the
compiler output to be sure the errors and/or warnings are exactly what
we expect.

* forc: Improve the `print_*_asm` CLI option docs (#2095)

Previously, these implied no bytecode was generated if the flag was not
set, however this is not the case.

* update fuelup related instructions (#2099)

* update fuelup instructions

* better instructions

* better wording for modifying path

* Adding `--time-phases` to `forc build` (#2091)

* make items under [project] ordered alphabetically in forc.toml

* issue #1893store/show bytecode hash

* formatted

* added cargo lock file

* cargo toml dependencies in alphabetical order

* hash bin of script or predicate only

* format

* generating bytecode hash only on scripts and predicates

* removed option from Compiled::tree_type

* ran clippy

* added to forc_build documentation

* made filename suffix containing bin hash a constant

* get root of predicate bytecode

* Apply suggestions from code review

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* if let to match on program type

* Update forc/src/cli/commands/build.rs

updating bin-root filename

Co-authored-by: mitchmindtree <mail@mitchellnordine.com>

* added benchmarks for compilation process

* use macro instead of closure for wrapping parts of compilation process

Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: Toby Hutton <toby@grusly.com>

* Add forc feature for overriding packages in the package graph, akin to cargo's [patch] feature (#1836)

* Bump to v0.16.2 (#2105)

* bump to v0.16.2

* Fix one test not pointing to local std

* Add struct formatting to sway-fmt-v2 (#2058)

* internal: Reduce amount of String::new() in sway-fmt-v2 (#2111)

* examples: fix renaming to BASE_ASSET_ID in comment (#2120)

* Added storage field alignment threshold to formatter config (#2113)

* Enable storage initializers and emit a storage initialization JSON (#2078)

* Enable storage initializers and dump out a JSON file

* Move the new functions into a separate storage module

* Use StorageSlot directly from fuel-tx

* forc deploy now uses the storage slots

* add some tests

* lint, change initializers -> slots, and fixing some tests

* enhance a comment

* Revert unneeded changes to sway-types

* add a failing test

* Fix failing test

* renaming some functions

* Test the storage slots JSON in e2e tests and add forc json-storage-slots command

* ignore *_output.json

* forc documenter changes

* Remove forc json-storage-slots and stop relying on forc json-abi

* Enhance some comments

* Remove unnecessary oracle

* Improve reserved keywords checking and add support for raw identifiers. (#2066)

Add support for raw identifiers and improve reserved keywords checking.

This commit deals with the usage and checking of reserved keywords
as identifiers, for code like:

```
fn main() {
    let mut mut = 0;
}

It introduces a new error that checks if an identifier is a reserved
keyword:

```
error
 --> /main.sw:4:13
  |
2 |
3 | fn main() {
4 |     let mut mut = 0;
  |             ^^^ Identifiers cannot be a reserved keyword.
5 | }
  |
____
```

There was an existing issue in the standard library, which
has a library/module named `storage`.

Instead of working around this by renaming it to something else,
an alternative solution with raw identifiers is implemented.

This raw identifier feature is implemented at the lexer level,
and allows you to use keywords as identifiers in places that
generally wouldn't be allowed.

Rust and a bunch of other modern languages also provide this escape
hatch, and it seemed the simplest solution for me to handle the issue.

It activates by declaring an identifier prefixed with `r#`, just like
Rust.

The complexity on the codebase to support this feature is pretty
minimal, but if there any objections to this, I can easily remove it,
but some other solution to the issue above will need to be figured out.

Closes #1996.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* remove `fuels-abigen-macro` dependency (#2007)

* add remove fuels-abigen-macro dependency

* add change dep. versions

* add fuel 0.16

* add fuel-core-lib flag

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add remove -- form forc test command

* add replace constants

* add expand CI command

* add fix tests

* add fix tests

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* add return -- cmd

* add remove fuels-abigen-macro from tests

* add remove fuel-core-lib flag

* add fuel-core-lib flag

* add reverte CI file

* add remove features

* add remove [features]

* add merge master

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Adds `Generics` handling to `sway-fmt-v2` (#2110)

* #2020 - changed BASE_ASSET_ID type to ContractId (#2137)

* #2020 - changed BASE_ASSET_ID type to ContractId

* Fix identity example

* Changes after review

* #2039 - add storage keyword highlighting in book (#2141)

* #2039 - add storage keyword highlighting in book

* Changes after review

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Add the U256 type (#2103)

* feat: add new bare u256 module to std

* feat: Add base type + from,into traits

* test: setup testing for U256

* cleanup

* feat: add impl U256 max, min, bits, new

* test: add new test assertions

* style: fmt

* test: generate oracle file

* Update sway-lib-std/src/u256.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* fix: remove * import

* fix: improve error handling

* test: better test coverage

* style: fmt

* docs: add test comments

* test: add more test cases for to_u64()

* fix: remove #r prefix from storage lib

* test: remove redundant test

* refactor: rename to_u64 to as_u64

* Revert "fix: remove #r prefix from storage lib"

This reverts commit 8dd0738.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* sway-fmt-v2 formatting should use tokens directly from sway-parse (#2097)

* Move monomorphization conceptually inside of the type engine (#2093)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Move the stuff.

* Move monomorphization conceptually inside of the type engine.

* Remove commented out test.

* `forc-pkg` - Don't add transitive deps (besides `core`) to a package's initial namespace (#2136)

`forc-pkg` - Don't add transitive deps (besides `core`) to namespace

Currently `forc-pkg` adds all transitive dependencies to a package's
initial namespace prior to its compilation. This had the benefit of
implicitly including `core`, but with the downside of implicitly
including every other transitive dependency package, even if not a
direct depednency (not what we want).

This PR changes the behaviour to only include direct dependencies and
`core` within a package's initial namespace.

Addresses 1, 2 of #2125.

* Demonstrate that `T` for `Vec` can now be inferred by arguments (#2132)

The bug is fixed.

* Remove unnecessary "core" str check in `Span::join` (#2156)

* Update the book to explicitly mention that `impl` functions can't call each other yet. (#2160)

* Remove duplicate CI checks that already have dedicated jobs (#2161)

I noticed a bunch of our CI jobs were were duplicating existing checks.
In particular, there was a lot of copy-paste steps of installing forc
and the forc-fmt plugin, even when unused in the following checks.

This doesn't improve the real bottleneck (our stdlib test job), but it's
a start.

* Speedup `find_dead_code` pass in control flow analysis (#2159)

Fix slow `find_dead_code` pass in control flow analysis

While waiting for the tests to pass on a PR I thought I'd have a quick
look to see if I could find any quick wins for dead code analysis #1952.

I noticed that that we're using `has_path_connecting` for every
combination of node and entry point. This means we were re-checking the
same nodes many, many times, searching from scratch each time and not
re-using any of the knowledge of already visited nodes in each
consecutive traversal.

This commit refactors the approach to first collect all known live nodes
into a set by traversing from the entry points. We re-use the same `Dfs`
when searching from each entry in order to re-use its inner set of
visited nodes and avoid re-searching sections of the graph that we've
already visited.

The dead nodes are those not contained in the live set after traversal.

This reduces the time taken within the `find_dead_code` call when
building the `std` library in debug from ~7.9 seconds down to ~3.3
milliseconds. 1000x+ speedup in DCA :)

Hopefully this speeds up our CI a bit!

Closes #1952.

* const initialization: a few fixes (#2158)

* const initialization: a few fixes

* cargo fmt

* Address review comments

* Add IR test

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Update broken link for contributing to Sway in README.md (#2172)

Closes #2171

* Backport improvements to `U128` type. (#2169)

* feat: improve U128 type errors & rename to_u264

* test: add tests for renamed as_u64

* Introduce `__eq` intrinsic (#2100)

* Introduce `__eq` intrinsic

* Lower to `Instruction::Cmp` instead of to assembly in IRGen

* Refactor intrinsics to all have arg and type arg vectors

* Improvements around `forc plugins` command (#1969)

Use the full path of the plugin when parsing it for a description.

This avoids the following panic caused by trying to exec an executable
in a sub-folder with a partial path:

```
~/dev/sway/target/debug$ forc plugins
Installed Plugins:
thread 'main' panicked at 'Could not get plugin description.: Os { code:
2, kind: NotFound, message: "No such file or directory" }',
forc/src/cli/commands/plugins.rs:43:10
stack backtrace:
   0: rust_begin_unwind
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::expect
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
   4: forc::cli::commands::plugins::parse_description_for_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:40:16
   5: forc::cli::commands::plugins::format_print_description
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:81:23
   6: forc::cli::commands::plugins::print_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:97:5
   7: forc::cli::commands::plugins::exec
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:28:21
```

* Updates `user_def` with `FieldAlignment` & fix corresponding use cases (#2153)

* update user_def with AlignFields & fix corresponding use cases

* rmv unused consts

* update doc comments in ItemEnum

* Add `lex_commented` and `CommentedTokenStream` to `sway_parse` (#2123)

* Add `CommentedTokenStream` to `sway_parse`

This doesn't yet collect any comments, but adds the necessary structure
and attempts to preserve the original API and behaviour where possible.

Collecting of comments to be added in a follow-up commit.

* Collect multi-line comments in CommentedTokenStream

* Collect single-line comments in CommentedTokenStream

* Add token_trees and spanned impls for CommentedTokenStream

* Add Spanned impl for CommentedTokenTree. Add comment lexing test.

* Expose `lex_commented` function from root

* Add CommentedTree and CommentedGroup aliases

* Move CommentedTokenTree impl to better location

* Clean up by using CommentedTree type alias where applicable

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>

* Remove unused field `const_decl_origin` from `TypedVariableDeclaration` (#2181)

Remove unused const_decl_origin from TypedVariableDeclaration

After #2158, constant declartaions use TypedConstantDeclaration
AST node, and hence this field is now useless. It must have been
removed in #2158 itself, but I missed doing that.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: bing <binggh@proton.me>
Co-authored-by: seem-less <mgirach@gmail.com>
Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: zhou fan <1247714429@qq.com>
Co-authored-by: Hlib Kanunnikov <hlibwondertan@gmail.com>
Co-authored-by: Emir <emirsalkicart@gmail.com>
Co-authored-by: r-sitko <19492095+r-sitko@users.noreply.github.com>
Co-authored-by: Nick Furfaro <nfurfaro33@gmail.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
SwayStar123 added a commit that referenced this pull request Jun 30, 2022
* Remove extra "the" (#2042)

looks like an extra "the" got into this comment

* Run `cargo update`. (#2045)

* sway-fmt-v2 adds program type to the output (#1997)

* Fix couple of bugs in handling returns in if blocks (#2029)

* Config driven E2E testing. (#2003)

Completely refactor E2E tests to be config driven.

Rather than specifying which tests are to be run and how, we now can
describe each test with a TOML file.

* Handle enums and their impls for item imports (#2034)

* Add `Identity` type to Sway Book (#2041)

* Add Identity type to Sway Book

* Move Identity code to examples directory

* Add Forc.lock to gitignore

* Update docs/src/basics/blockchain_types.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Typo

* Ran forc fmt

* Update Cargo.toml

* Update examples/identity/src/main.sw

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Delete Cargo.toml

* Update Identity docs to use anchor

* Fix CI

* Add path to std in Forc.toml and update Forc.lock std source

* Run forc fmt again

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Improve struct patterns with new warnings and rest pattern support. (#2032)

* Improve struct patterns with new warnings and rest pattern support.

This commit improves a couple aspects of handling of struct patterns.

First of all, it adds semantic checking (with a new warning) when
patterns are missing usage of all fields:

```
error
  --> src/main.sw:15:9
   |
13 |
14 |     let z = match p {
15 |         Point { x } => { x },
   |         ^^^^^^^^^^^ Pattern does not mention field: y
16 |     };
   |
____
```

Then it adds support for rest pattern, "..", which can be used as the
last token in a pattern to not have to specify all the struct fields.

The semantic AST model was updated to support modeling this pattern,
and further type checking was added to the code.

There is also a new warning for when the rest pattern doesn't appear as
the last location, or when it appears multiple times:

```
error
  --> src/main.sw:17:20
   |
15 |
16 |     let z = match p {
17 |         Point { x, .., .. } => { x },
|                    ^^ Unexpected rest token, must be at the end of
pattern.
18 |     };
   |
____
```

And lastly, tests were added to cover the changes and new functionality.

Closes #1568.

* Do not use an underscored identifier.

* Add some more pattern matching tests.

* Port to new config-driven tests.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Add the concept of semantic similarity to the type system (#1958)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Some updates to the known issues section (#2060)

Updates to the known issues section

* Constants formatting for sway-fmt-v2 (#2021)

* Update the check for unresolved types. (#2057)

* Update the check for unresolved types.

* clippy

* Remove calls to log.

* fmt

* Remove unused file.

* Make `resolve_type_with_self` and `resolve_type_without_self` take `TypeId`'s instead of `TypeInfo`'s (#1982)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Bump non-transitive `dashmap` to v5.3.4. (#2062)

Bump explicit `dashmap` to v5.3.4.

* comby-rust (#2065)

* comby-rust

* Fix clippy warning

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Adds `attribute` handling to `sway-fmt-v2` (#2061)

* wip

* add unit test

* update tests

* updated unimplemented cases to return span

* test now passes incorrectly

* update AttributeDecl::format()

* update test comment

* add close paren

* update Annotated for consistency

* chng return type for Annotated

* remove test and add todos

* Introduce a type check `Context`. Replaces `TypeCheckArguments`. (#2004)

* Introduce a type check `Context`. Replaces `TypeCheckArguments`.

* Add missing unknown type annotation. Clean up some formatting.

Also adds some resetting of the help text and type annotation (to
unknown) in many cases to better match the original behaviour. It's
difficult to tell which locations these values were originally used as
placeholders, and which locations they're a necessity for correctness.
This at least appears to fix an issue with expression return type
inference.

* Rename semantic_analysis::Context to TypeCheckContext

* Improve field doc comments for help_text, self_type

* Add doc comment to mode field in TypeCheckContext

* Construct TypeCheckContext at Program level, not module level.

This should help to clarify how we can pass other type check context
(like the declaration and type engines once they're added) through to
the submodules. Previously, this was a little unclear as the
`TypeCheckContext` was only constructed at the module level.

* Add missing namespace field doc comment to TypeCheckContext

* Fix TypeCheckContext constructor in IR test

* Add `forc check` command (#2026)

* wip

* moving back to PC computer

* adding check function to forc pkg

* have ast returning from forc pkg

* can now successfully parse all sway examples

* fmt

* added forc check

* tidy up lsp tests

* add forc check command

* forc ops doesnt need to be public

* tidy up lsp tests

* remove non relevant code

* rebase on master

* add Cargo.lock file

* add forc check to mdbook

* Small fixes to the `storage_map` example (#2079)

Small fix to storage_map example

* Move `TypeArgument`, `TypeParameter`, and `TraitConstraints` to be conceptually inside of the type engine (#2074)

Move the stuff.

* Ensure lock is applied when `BuildPlan` validation would require changes (#2090)

Ensure lock is applied if BuildPlan validation requires changes

While reviewing #2085, I noticed that some recent additions to
`BuildPlan` validation could result in some changes to the build plan
(and in turn, rewriting the lock file) even in the case that `--locked`
was specified.

This moves the `--locked` check to the moment before writing the new
lock file. This ensures all potential changes that would be required of
the `BuildPlan` are caught. It also allows us to provide a "Cause" for
*why* the lock file would need updating when `--locked` is passed to
prevent it.

Closes #2084
Closes #2085

* Add conceptual distinction between replacing `TypeInfo::Self` and monomorphization (#2017)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Add `abi` handling to `sway-fmt-v2` (#2044)

* Refactor `forc_pkg::BuildConfig` -> `BuildProfile`, fix CLI arg handling (#2094)

Previously, if any of the `print` args were set, the rest of the
selected build profile was ignored. This changes the behaviour so that
the command line arguments only override their associated build profile
fields.

Also renames `BuildConfig` to `BuildProfile` and moves it from
`forc_pkg::pkg` to `forc_pkg::manifest` along with the rest of the
serializable manifest types.

* Update all the E2E should_fail tests to verify their output. (#2082)

Using the `FileCheck` crate it can now pattern match against the
compiler output to be sure the errors and/or warnings are exactly what
we expect.

* forc: Improve the `print_*_asm` CLI option docs (#2095)

Previously, these implied no bytecode was generated if the flag was not
set, however this is not the case.

* update fuelup related instructions (#2099)

* update fuelup instructions

* better instructions

* better wording for modifying path

* Adding `--time-phases` to `forc build` (#2091)

* make items under [project] ordered alphabetically in forc.toml

* issue #1893store/show bytecode hash

* formatted

* added cargo lock file

* cargo toml dependencies in alphabetical order

* hash bin of script or predicate only

* format

* generating bytecode hash only on scripts and predicates

* removed option from Compiled::tree_type

* ran clippy

* added to forc_build documentation

* made filename suffix containing bin hash a constant

* get root of predicate bytecode

* Apply suggestions from code review

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* if let to match on program type

* Update forc/src/cli/commands/build.rs

updating bin-root filename

Co-authored-by: mitchmindtree <mail@mitchellnordine.com>

* added benchmarks for compilation process

* use macro instead of closure for wrapping parts of compilation process

Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: Toby Hutton <toby@grusly.com>

* Add forc feature for overriding packages in the package graph, akin to cargo's [patch] feature (#1836)

* Bump to v0.16.2 (#2105)

* bump to v0.16.2

* Fix one test not pointing to local std

* Add struct formatting to sway-fmt-v2 (#2058)

* internal: Reduce amount of String::new() in sway-fmt-v2 (#2111)

* examples: fix renaming to BASE_ASSET_ID in comment (#2120)

* Added storage field alignment threshold to formatter config (#2113)

* Enable storage initializers and emit a storage initialization JSON (#2078)

* Enable storage initializers and dump out a JSON file

* Move the new functions into a separate storage module

* Use StorageSlot directly from fuel-tx

* forc deploy now uses the storage slots

* add some tests

* lint, change initializers -> slots, and fixing some tests

* enhance a comment

* Revert unneeded changes to sway-types

* add a failing test

* Fix failing test

* renaming some functions

* Test the storage slots JSON in e2e tests and add forc json-storage-slots command

* ignore *_output.json

* forc documenter changes

* Remove forc json-storage-slots and stop relying on forc json-abi

* Enhance some comments

* Remove unnecessary oracle

* Improve reserved keywords checking and add support for raw identifiers. (#2066)

Add support for raw identifiers and improve reserved keywords checking.

This commit deals with the usage and checking of reserved keywords
as identifiers, for code like:

```
fn main() {
    let mut mut = 0;
}

It introduces a new error that checks if an identifier is a reserved
keyword:

```
error
 --> /main.sw:4:13
  |
2 |
3 | fn main() {
4 |     let mut mut = 0;
  |             ^^^ Identifiers cannot be a reserved keyword.
5 | }
  |
____
```

There was an existing issue in the standard library, which
has a library/module named `storage`.

Instead of working around this by renaming it to something else,
an alternative solution with raw identifiers is implemented.

This raw identifier feature is implemented at the lexer level,
and allows you to use keywords as identifiers in places that
generally wouldn't be allowed.

Rust and a bunch of other modern languages also provide this escape
hatch, and it seemed the simplest solution for me to handle the issue.

It activates by declaring an identifier prefixed with `r#`, just like
Rust.

The complexity on the codebase to support this feature is pretty
minimal, but if there any objections to this, I can easily remove it,
but some other solution to the issue above will need to be figured out.

Closes #1996.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* remove `fuels-abigen-macro` dependency (#2007)

* add remove fuels-abigen-macro dependency

* add change dep. versions

* add fuel 0.16

* add fuel-core-lib flag

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add remove -- form forc test command

* add replace constants

* add expand CI command

* add fix tests

* add fix tests

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* add return -- cmd

* add remove fuels-abigen-macro from tests

* add remove fuel-core-lib flag

* add fuel-core-lib flag

* add reverte CI file

* add remove features

* add remove [features]

* add merge master

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Adds `Generics` handling to `sway-fmt-v2` (#2110)

* #2020 - changed BASE_ASSET_ID type to ContractId (#2137)

* #2020 - changed BASE_ASSET_ID type to ContractId

* Fix identity example

* Changes after review

* #2039 - add storage keyword highlighting in book (#2141)

* #2039 - add storage keyword highlighting in book

* Changes after review

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Add the U256 type (#2103)

* feat: add new bare u256 module to std

* feat: Add base type + from,into traits

* test: setup testing for U256

* cleanup

* feat: add impl U256 max, min, bits, new

* test: add new test assertions

* style: fmt

* test: generate oracle file

* Update sway-lib-std/src/u256.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* fix: remove * import

* fix: improve error handling

* test: better test coverage

* style: fmt

* docs: add test comments

* test: add more test cases for to_u64()

* fix: remove #r prefix from storage lib

* test: remove redundant test

* refactor: rename to_u64 to as_u64

* Revert "fix: remove #r prefix from storage lib"

This reverts commit 8dd0738.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* sway-fmt-v2 formatting should use tokens directly from sway-parse (#2097)

* Move monomorphization conceptually inside of the type engine (#2093)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Move the stuff.

* Move monomorphization conceptually inside of the type engine.

* Remove commented out test.

* `forc-pkg` - Don't add transitive deps (besides `core`) to a package's initial namespace (#2136)

`forc-pkg` - Don't add transitive deps (besides `core`) to namespace

Currently `forc-pkg` adds all transitive dependencies to a package's
initial namespace prior to its compilation. This had the benefit of
implicitly including `core`, but with the downside of implicitly
including every other transitive dependency package, even if not a
direct depednency (not what we want).

This PR changes the behaviour to only include direct dependencies and
`core` within a package's initial namespace.

Addresses 1, 2 of #2125.

* Demonstrate that `T` for `Vec` can now be inferred by arguments (#2132)

The bug is fixed.

* Remove unnecessary "core" str check in `Span::join` (#2156)

* Update the book to explicitly mention that `impl` functions can't call each other yet. (#2160)

* Remove duplicate CI checks that already have dedicated jobs (#2161)

I noticed a bunch of our CI jobs were were duplicating existing checks.
In particular, there was a lot of copy-paste steps of installing forc
and the forc-fmt plugin, even when unused in the following checks.

This doesn't improve the real bottleneck (our stdlib test job), but it's
a start.

* Speedup `find_dead_code` pass in control flow analysis (#2159)

Fix slow `find_dead_code` pass in control flow analysis

While waiting for the tests to pass on a PR I thought I'd have a quick
look to see if I could find any quick wins for dead code analysis #1952.

I noticed that that we're using `has_path_connecting` for every
combination of node and entry point. This means we were re-checking the
same nodes many, many times, searching from scratch each time and not
re-using any of the knowledge of already visited nodes in each
consecutive traversal.

This commit refactors the approach to first collect all known live nodes
into a set by traversing from the entry points. We re-use the same `Dfs`
when searching from each entry in order to re-use its inner set of
visited nodes and avoid re-searching sections of the graph that we've
already visited.

The dead nodes are those not contained in the live set after traversal.

This reduces the time taken within the `find_dead_code` call when
building the `std` library in debug from ~7.9 seconds down to ~3.3
milliseconds. 1000x+ speedup in DCA :)

Hopefully this speeds up our CI a bit!

Closes #1952.

* const initialization: a few fixes (#2158)

* const initialization: a few fixes

* cargo fmt

* Address review comments

* Add IR test

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Update broken link for contributing to Sway in README.md (#2172)

Closes #2171

* Backport improvements to `U128` type. (#2169)

* feat: improve U128 type errors & rename to_u264

* test: add tests for renamed as_u64

* Introduce `__eq` intrinsic (#2100)

* Introduce `__eq` intrinsic

* Lower to `Instruction::Cmp` instead of to assembly in IRGen

* Refactor intrinsics to all have arg and type arg vectors

* Improvements around `forc plugins` command (#1969)

Use the full path of the plugin when parsing it for a description.

This avoids the following panic caused by trying to exec an executable
in a sub-folder with a partial path:

```
~/dev/sway/target/debug$ forc plugins
Installed Plugins:
thread 'main' panicked at 'Could not get plugin description.: Os { code:
2, kind: NotFound, message: "No such file or directory" }',
forc/src/cli/commands/plugins.rs:43:10
stack backtrace:
   0: rust_begin_unwind
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::expect
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
   4: forc::cli::commands::plugins::parse_description_for_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:40:16
   5: forc::cli::commands::plugins::format_print_description
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:81:23
   6: forc::cli::commands::plugins::print_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:97:5
   7: forc::cli::commands::plugins::exec
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:28:21
```

* Updates `user_def` with `FieldAlignment` & fix corresponding use cases (#2153)

* update user_def with AlignFields & fix corresponding use cases

* rmv unused consts

* update doc comments in ItemEnum

* Add `lex_commented` and `CommentedTokenStream` to `sway_parse` (#2123)

* Add `CommentedTokenStream` to `sway_parse`

This doesn't yet collect any comments, but adds the necessary structure
and attempts to preserve the original API and behaviour where possible.

Collecting of comments to be added in a follow-up commit.

* Collect multi-line comments in CommentedTokenStream

* Collect single-line comments in CommentedTokenStream

* Add token_trees and spanned impls for CommentedTokenStream

* Add Spanned impl for CommentedTokenTree. Add comment lexing test.

* Expose `lex_commented` function from root

* Add CommentedTree and CommentedGroup aliases

* Move CommentedTokenTree impl to better location

* Clean up by using CommentedTree type alias where applicable

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>

* Remove unused field `const_decl_origin` from `TypedVariableDeclaration` (#2181)

Remove unused const_decl_origin from TypedVariableDeclaration

After #2158, constant declartaions use TypedConstantDeclaration
AST node, and hence this field is now useless. It must have been
removed in #2158 itself, but I missed doing that.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: bing <binggh@proton.me>
Co-authored-by: seem-less <mgirach@gmail.com>
Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: zhou fan <1247714429@qq.com>
Co-authored-by: Hlib Kanunnikov <hlibwondertan@gmail.com>
Co-authored-by: Emir <emirsalkicart@gmail.com>
Co-authored-by: r-sitko <19492095+r-sitko@users.noreply.github.com>
Co-authored-by: Nick Furfaro <nfurfaro33@gmail.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
SwayStar123 added a commit that referenced this pull request Jul 14, 2022
* Initial commit - storagevec

* added an error and comments and documentation

* fixed the order of the Result types

* added suggested functions

* removed unncessary code

* renamed remove_index

* added swap remove and removed unncessary annotations

* moved storage_vec to storage and started on tests

* built some of the contract -- WIP

* made it so swap_remove returns the removed element

* removed extra ) and added all the test functions

* fixed a syntax error

* changed store to storage

* removed all other types for now

* made storagevecerror public

* removed unncessary code to streamline bugfixing

* fixed annotations

* made all the test contracts

* changed build.sh to include all the storage_vec projs

* updated fuels version

* unwrapped all results and options in the contract

* reduced fuels version

* merge master to storage_vec branch (#2183)

* Remove extra "the" (#2042)

looks like an extra "the" got into this comment

* Run `cargo update`. (#2045)

* sway-fmt-v2 adds program type to the output (#1997)

* Fix couple of bugs in handling returns in if blocks (#2029)

* Config driven E2E testing. (#2003)

Completely refactor E2E tests to be config driven.

Rather than specifying which tests are to be run and how, we now can
describe each test with a TOML file.

* Handle enums and their impls for item imports (#2034)

* Add `Identity` type to Sway Book (#2041)

* Add Identity type to Sway Book

* Move Identity code to examples directory

* Add Forc.lock to gitignore

* Update docs/src/basics/blockchain_types.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Typo

* Ran forc fmt

* Update Cargo.toml

* Update examples/identity/src/main.sw

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Delete Cargo.toml

* Update Identity docs to use anchor

* Fix CI

* Add path to std in Forc.toml and update Forc.lock std source

* Run forc fmt again

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Improve struct patterns with new warnings and rest pattern support. (#2032)

* Improve struct patterns with new warnings and rest pattern support.

This commit improves a couple aspects of handling of struct patterns.

First of all, it adds semantic checking (with a new warning) when
patterns are missing usage of all fields:

```
error
  --> src/main.sw:15:9
   |
13 |
14 |     let z = match p {
15 |         Point { x } => { x },
   |         ^^^^^^^^^^^ Pattern does not mention field: y
16 |     };
   |
____
```

Then it adds support for rest pattern, "..", which can be used as the
last token in a pattern to not have to specify all the struct fields.

The semantic AST model was updated to support modeling this pattern,
and further type checking was added to the code.

There is also a new warning for when the rest pattern doesn't appear as
the last location, or when it appears multiple times:

```
error
  --> src/main.sw:17:20
   |
15 |
16 |     let z = match p {
17 |         Point { x, .., .. } => { x },
|                    ^^ Unexpected rest token, must be at the end of
pattern.
18 |     };
   |
____
```

And lastly, tests were added to cover the changes and new functionality.

Closes #1568.

* Do not use an underscored identifier.

* Add some more pattern matching tests.

* Port to new config-driven tests.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Add the concept of semantic similarity to the type system (#1958)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Some updates to the known issues section (#2060)

Updates to the known issues section

* Constants formatting for sway-fmt-v2 (#2021)

* Update the check for unresolved types. (#2057)

* Update the check for unresolved types.

* clippy

* Remove calls to log.

* fmt

* Remove unused file.

* Make `resolve_type_with_self` and `resolve_type_without_self` take `TypeId`'s instead of `TypeInfo`'s (#1982)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Bump non-transitive `dashmap` to v5.3.4. (#2062)

Bump explicit `dashmap` to v5.3.4.

* comby-rust (#2065)

* comby-rust

* Fix clippy warning

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Adds `attribute` handling to `sway-fmt-v2` (#2061)

* wip

* add unit test

* update tests

* updated unimplemented cases to return span

* test now passes incorrectly

* update AttributeDecl::format()

* update test comment

* add close paren

* update Annotated for consistency

* chng return type for Annotated

* remove test and add todos

* Introduce a type check `Context`. Replaces `TypeCheckArguments`. (#2004)

* Introduce a type check `Context`. Replaces `TypeCheckArguments`.

* Add missing unknown type annotation. Clean up some formatting.

Also adds some resetting of the help text and type annotation (to
unknown) in many cases to better match the original behaviour. It's
difficult to tell which locations these values were originally used as
placeholders, and which locations they're a necessity for correctness.
This at least appears to fix an issue with expression return type
inference.

* Rename semantic_analysis::Context to TypeCheckContext

* Improve field doc comments for help_text, self_type

* Add doc comment to mode field in TypeCheckContext

* Construct TypeCheckContext at Program level, not module level.

This should help to clarify how we can pass other type check context
(like the declaration and type engines once they're added) through to
the submodules. Previously, this was a little unclear as the
`TypeCheckContext` was only constructed at the module level.

* Add missing namespace field doc comment to TypeCheckContext

* Fix TypeCheckContext constructor in IR test

* Add `forc check` command (#2026)

* wip

* moving back to PC computer

* adding check function to forc pkg

* have ast returning from forc pkg

* can now successfully parse all sway examples

* fmt

* added forc check

* tidy up lsp tests

* add forc check command

* forc ops doesnt need to be public

* tidy up lsp tests

* remove non relevant code

* rebase on master

* add Cargo.lock file

* add forc check to mdbook

* Small fixes to the `storage_map` example (#2079)

Small fix to storage_map example

* Move `TypeArgument`, `TypeParameter`, and `TraitConstraints` to be conceptually inside of the type engine (#2074)

Move the stuff.

* Ensure lock is applied when `BuildPlan` validation would require changes (#2090)

Ensure lock is applied if BuildPlan validation requires changes

While reviewing #2085, I noticed that some recent additions to
`BuildPlan` validation could result in some changes to the build plan
(and in turn, rewriting the lock file) even in the case that `--locked`
was specified.

This moves the `--locked` check to the moment before writing the new
lock file. This ensures all potential changes that would be required of
the `BuildPlan` are caught. It also allows us to provide a "Cause" for
*why* the lock file would need updating when `--locked` is passed to
prevent it.

Closes #2084
Closes #2085

* Add conceptual distinction between replacing `TypeInfo::Self` and monomorphization (#2017)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Add `abi` handling to `sway-fmt-v2` (#2044)

* Refactor `forc_pkg::BuildConfig` -> `BuildProfile`, fix CLI arg handling (#2094)

Previously, if any of the `print` args were set, the rest of the
selected build profile was ignored. This changes the behaviour so that
the command line arguments only override their associated build profile
fields.

Also renames `BuildConfig` to `BuildProfile` and moves it from
`forc_pkg::pkg` to `forc_pkg::manifest` along with the rest of the
serializable manifest types.

* Update all the E2E should_fail tests to verify their output. (#2082)

Using the `FileCheck` crate it can now pattern match against the
compiler output to be sure the errors and/or warnings are exactly what
we expect.

* forc: Improve the `print_*_asm` CLI option docs (#2095)

Previously, these implied no bytecode was generated if the flag was not
set, however this is not the case.

* update fuelup related instructions (#2099)

* update fuelup instructions

* better instructions

* better wording for modifying path

* Adding `--time-phases` to `forc build` (#2091)

* make items under [project] ordered alphabetically in forc.toml

* issue #1893store/show bytecode hash

* formatted

* added cargo lock file

* cargo toml dependencies in alphabetical order

* hash bin of script or predicate only

* format

* generating bytecode hash only on scripts and predicates

* removed option from Compiled::tree_type

* ran clippy

* added to forc_build documentation

* made filename suffix containing bin hash a constant

* get root of predicate bytecode

* Apply suggestions from code review

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* if let to match on program type

* Update forc/src/cli/commands/build.rs

updating bin-root filename

Co-authored-by: mitchmindtree <mail@mitchellnordine.com>

* added benchmarks for compilation process

* use macro instead of closure for wrapping parts of compilation process

Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: Toby Hutton <toby@grusly.com>

* Add forc feature for overriding packages in the package graph, akin to cargo's [patch] feature (#1836)

* Bump to v0.16.2 (#2105)

* bump to v0.16.2

* Fix one test not pointing to local std

* Add struct formatting to sway-fmt-v2 (#2058)

* internal: Reduce amount of String::new() in sway-fmt-v2 (#2111)

* examples: fix renaming to BASE_ASSET_ID in comment (#2120)

* Added storage field alignment threshold to formatter config (#2113)

* Enable storage initializers and emit a storage initialization JSON (#2078)

* Enable storage initializers and dump out a JSON file

* Move the new functions into a separate storage module

* Use StorageSlot directly from fuel-tx

* forc deploy now uses the storage slots

* add some tests

* lint, change initializers -> slots, and fixing some tests

* enhance a comment

* Revert unneeded changes to sway-types

* add a failing test

* Fix failing test

* renaming some functions

* Test the storage slots JSON in e2e tests and add forc json-storage-slots command

* ignore *_output.json

* forc documenter changes

* Remove forc json-storage-slots and stop relying on forc json-abi

* Enhance some comments

* Remove unnecessary oracle

* Improve reserved keywords checking and add support for raw identifiers. (#2066)

Add support for raw identifiers and improve reserved keywords checking.

This commit deals with the usage and checking of reserved keywords
as identifiers, for code like:

```
fn main() {
    let mut mut = 0;
}

It introduces a new error that checks if an identifier is a reserved
keyword:

```
error
 --> /main.sw:4:13
  |
2 |
3 | fn main() {
4 |     let mut mut = 0;
  |             ^^^ Identifiers cannot be a reserved keyword.
5 | }
  |
____
```

There was an existing issue in the standard library, which
has a library/module named `storage`.

Instead of working around this by renaming it to something else,
an alternative solution with raw identifiers is implemented.

This raw identifier feature is implemented at the lexer level,
and allows you to use keywords as identifiers in places that
generally wouldn't be allowed.

Rust and a bunch of other modern languages also provide this escape
hatch, and it seemed the simplest solution for me to handle the issue.

It activates by declaring an identifier prefixed with `r#`, just like
Rust.

The complexity on the codebase to support this feature is pretty
minimal, but if there any objections to this, I can easily remove it,
but some other solution to the issue above will need to be figured out.

Closes #1996.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* remove `fuels-abigen-macro` dependency (#2007)

* add remove fuels-abigen-macro dependency

* add change dep. versions

* add fuel 0.16

* add fuel-core-lib flag

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add remove -- form forc test command

* add replace constants

* add expand CI command

* add fix tests

* add fix tests

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* add return -- cmd

* add remove fuels-abigen-macro from tests

* add remove fuel-core-lib flag

* add fuel-core-lib flag

* add reverte CI file

* add remove features

* add remove [features]

* add merge master

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Adds `Generics` handling to `sway-fmt-v2` (#2110)

* #2020 - changed BASE_ASSET_ID type to ContractId (#2137)

* #2020 - changed BASE_ASSET_ID type to ContractId

* Fix identity example

* Changes after review

* #2039 - add storage keyword highlighting in book (#2141)

* #2039 - add storage keyword highlighting in book

* Changes after review

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Add the U256 type (#2103)

* feat: add new bare u256 module to std

* feat: Add base type + from,into traits

* test: setup testing for U256

* cleanup

* feat: add impl U256 max, min, bits, new

* test: add new test assertions

* style: fmt

* test: generate oracle file

* Update sway-lib-std/src/u256.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* fix: remove * import

* fix: improve error handling

* test: better test coverage

* style: fmt

* docs: add test comments

* test: add more test cases for to_u64()

* fix: remove #r prefix from storage lib

* test: remove redundant test

* refactor: rename to_u64 to as_u64

* Revert "fix: remove #r prefix from storage lib"

This reverts commit 8dd0738.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* sway-fmt-v2 formatting should use tokens directly from sway-parse (#2097)

* Move monomorphization conceptually inside of the type engine (#2093)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Move the stuff.

* Move monomorphization conceptually inside of the type engine.

* Remove commented out test.

* `forc-pkg` - Don't add transitive deps (besides `core`) to a package's initial namespace (#2136)

`forc-pkg` - Don't add transitive deps (besides `core`) to namespace

Currently `forc-pkg` adds all transitive dependencies to a package's
initial namespace prior to its compilation. This had the benefit of
implicitly including `core`, but with the downside of implicitly
including every other transitive dependency package, even if not a
direct depednency (not what we want).

This PR changes the behaviour to only include direct dependencies and
`core` within a package's initial namespace.

Addresses 1, 2 of #2125.

* Demonstrate that `T` for `Vec` can now be inferred by arguments (#2132)

The bug is fixed.

* Remove unnecessary "core" str check in `Span::join` (#2156)

* Update the book to explicitly mention that `impl` functions can't call each other yet. (#2160)

* Remove duplicate CI checks that already have dedicated jobs (#2161)

I noticed a bunch of our CI jobs were were duplicating existing checks.
In particular, there was a lot of copy-paste steps of installing forc
and the forc-fmt plugin, even when unused in the following checks.

This doesn't improve the real bottleneck (our stdlib test job), but it's
a start.

* Speedup `find_dead_code` pass in control flow analysis (#2159)

Fix slow `find_dead_code` pass in control flow analysis

While waiting for the tests to pass on a PR I thought I'd have a quick
look to see if I could find any quick wins for dead code analysis #1952.

I noticed that that we're using `has_path_connecting` for every
combination of node and entry point. This means we were re-checking the
same nodes many, many times, searching from scratch each time and not
re-using any of the knowledge of already visited nodes in each
consecutive traversal.

This commit refactors the approach to first collect all known live nodes
into a set by traversing from the entry points. We re-use the same `Dfs`
when searching from each entry in order to re-use its inner set of
visited nodes and avoid re-searching sections of the graph that we've
already visited.

The dead nodes are those not contained in the live set after traversal.

This reduces the time taken within the `find_dead_code` call when
building the `std` library in debug from ~7.9 seconds down to ~3.3
milliseconds. 1000x+ speedup in DCA :)

Hopefully this speeds up our CI a bit!

Closes #1952.

* const initialization: a few fixes (#2158)

* const initialization: a few fixes

* cargo fmt

* Address review comments

* Add IR test

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Update broken link for contributing to Sway in README.md (#2172)

Closes #2171

* Backport improvements to `U128` type. (#2169)

* feat: improve U128 type errors & rename to_u264

* test: add tests for renamed as_u64

* Introduce `__eq` intrinsic (#2100)

* Introduce `__eq` intrinsic

* Lower to `Instruction::Cmp` instead of to assembly in IRGen

* Refactor intrinsics to all have arg and type arg vectors

* Improvements around `forc plugins` command (#1969)

Use the full path of the plugin when parsing it for a description.

This avoids the following panic caused by trying to exec an executable
in a sub-folder with a partial path:

```
~/dev/sway/target/debug$ forc plugins
Installed Plugins:
thread 'main' panicked at 'Could not get plugin description.: Os { code:
2, kind: NotFound, message: "No such file or directory" }',
forc/src/cli/commands/plugins.rs:43:10
stack backtrace:
   0: rust_begin_unwind
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::expect
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
   4: forc::cli::commands::plugins::parse_description_for_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:40:16
   5: forc::cli::commands::plugins::format_print_description
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:81:23
   6: forc::cli::commands::plugins::print_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:97:5
   7: forc::cli::commands::plugins::exec
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:28:21
```

* Updates `user_def` with `FieldAlignment` & fix corresponding use cases (#2153)

* update user_def with AlignFields & fix corresponding use cases

* rmv unused consts

* update doc comments in ItemEnum

* Add `lex_commented` and `CommentedTokenStream` to `sway_parse` (#2123)

* Add `CommentedTokenStream` to `sway_parse`

This doesn't yet collect any comments, but adds the necessary structure
and attempts to preserve the original API and behaviour where possible.

Collecting of comments to be added in a follow-up commit.

* Collect multi-line comments in CommentedTokenStream

* Collect single-line comments in CommentedTokenStream

* Add token_trees and spanned impls for CommentedTokenStream

* Add Spanned impl for CommentedTokenTree. Add comment lexing test.

* Expose `lex_commented` function from root

* Add CommentedTree and CommentedGroup aliases

* Move CommentedTokenTree impl to better location

* Clean up by using CommentedTree type alias where applicable

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>

* Remove unused field `const_decl_origin` from `TypedVariableDeclaration` (#2181)

Remove unused const_decl_origin from TypedVariableDeclaration

After #2158, constant declartaions use TypedConstantDeclaration
AST node, and hence this field is now useless. It must have been
removed in #2158 itself, but I missed doing that.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: bing <binggh@proton.me>
Co-authored-by: seem-less <mgirach@gmail.com>
Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: zhou fan <1247714429@qq.com>
Co-authored-by: Hlib Kanunnikov <hlibwondertan@gmail.com>
Co-authored-by: Emir <emirsalkicart@gmail.com>
Co-authored-by: r-sitko <19492095+r-sitko@users.noreply.github.com>
Co-authored-by: Nick Furfaro <nfurfaro33@gmail.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>

* merge master to storage_vec (#2184)

* Remove extra "the" (#2042)

looks like an extra "the" got into this comment

* Run `cargo update`. (#2045)

* sway-fmt-v2 adds program type to the output (#1997)

* Fix couple of bugs in handling returns in if blocks (#2029)

* Config driven E2E testing. (#2003)

Completely refactor E2E tests to be config driven.

Rather than specifying which tests are to be run and how, we now can
describe each test with a TOML file.

* Handle enums and their impls for item imports (#2034)

* Add `Identity` type to Sway Book (#2041)

* Add Identity type to Sway Book

* Move Identity code to examples directory

* Add Forc.lock to gitignore

* Update docs/src/basics/blockchain_types.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Typo

* Ran forc fmt

* Update Cargo.toml

* Update examples/identity/src/main.sw

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Delete Cargo.toml

* Update Identity docs to use anchor

* Fix CI

* Add path to std in Forc.toml and update Forc.lock std source

* Run forc fmt again

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Improve struct patterns with new warnings and rest pattern support. (#2032)

* Improve struct patterns with new warnings and rest pattern support.

This commit improves a couple aspects of handling of struct patterns.

First of all, it adds semantic checking (with a new warning) when
patterns are missing usage of all fields:

```
error
  --> src/main.sw:15:9
   |
13 |
14 |     let z = match p {
15 |         Point { x } => { x },
   |         ^^^^^^^^^^^ Pattern does not mention field: y
16 |     };
   |
____
```

Then it adds support for rest pattern, "..", which can be used as the
last token in a pattern to not have to specify all the struct fields.

The semantic AST model was updated to support modeling this pattern,
and further type checking was added to the code.

There is also a new warning for when the rest pattern doesn't appear as
the last location, or when it appears multiple times:

```
error
  --> src/main.sw:17:20
   |
15 |
16 |     let z = match p {
17 |         Point { x, .., .. } => { x },
|                    ^^ Unexpected rest token, must be at the end of
pattern.
18 |     };
   |
____
```

And lastly, tests were added to cover the changes and new functionality.

Closes #1568.

* Do not use an underscored identifier.

* Add some more pattern matching tests.

* Port to new config-driven tests.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Add the concept of semantic similarity to the type system (#1958)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Some updates to the known issues section (#2060)

Updates to the known issues section

* Constants formatting for sway-fmt-v2 (#2021)

* Update the check for unresolved types. (#2057)

* Update the check for unresolved types.

* clippy

* Remove calls to log.

* fmt

* Remove unused file.

* Make `resolve_type_with_self` and `resolve_type_without_self` take `TypeId`'s instead of `TypeInfo`'s (#1982)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Bump non-transitive `dashmap` to v5.3.4. (#2062)

Bump explicit `dashmap` to v5.3.4.

* comby-rust (#2065)

* comby-rust

* Fix clippy warning

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Adds `attribute` handling to `sway-fmt-v2` (#2061)

* wip

* add unit test

* update tests

* updated unimplemented cases to return span

* test now passes incorrectly

* update AttributeDecl::format()

* update test comment

* add close paren

* update Annotated for consistency

* chng return type for Annotated

* remove test and add todos

* Introduce a type check `Context`. Replaces `TypeCheckArguments`. (#2004)

* Introduce a type check `Context`. Replaces `TypeCheckArguments`.

* Add missing unknown type annotation. Clean up some formatting.

Also adds some resetting of the help text and type annotation (to
unknown) in many cases to better match the original behaviour. It's
difficult to tell which locations these values were originally used as
placeholders, and which locations they're a necessity for correctness.
This at least appears to fix an issue with expression return type
inference.

* Rename semantic_analysis::Context to TypeCheckContext

* Improve field doc comments for help_text, self_type

* Add doc comment to mode field in TypeCheckContext

* Construct TypeCheckContext at Program level, not module level.

This should help to clarify how we can pass other type check context
(like the declaration and type engines once they're added) through to
the submodules. Previously, this was a little unclear as the
`TypeCheckContext` was only constructed at the module level.

* Add missing namespace field doc comment to TypeCheckContext

* Fix TypeCheckContext constructor in IR test

* Add `forc check` command (#2026)

* wip

* moving back to PC computer

* adding check function to forc pkg

* have ast returning from forc pkg

* can now successfully parse all sway examples

* fmt

* added forc check

* tidy up lsp tests

* add forc check command

* forc ops doesnt need to be public

* tidy up lsp tests

* remove non relevant code

* rebase on master

* add Cargo.lock file

* add forc check to mdbook

* Small fixes to the `storage_map` example (#2079)

Small fix to storage_map example

* Move `TypeArgument`, `TypeParameter`, and `TraitConstraints` to be conceptually inside of the type engine (#2074)

Move the stuff.

* Ensure lock is applied when `BuildPlan` validation would require changes (#2090)

Ensure lock is applied if BuildPlan validation requires changes

While reviewing #2085, I noticed that some recent additions to
`BuildPlan` validation could result in some changes to the build plan
(and in turn, rewriting the lock file) even in the case that `--locked`
was specified.

This moves the `--locked` check to the moment before writing the new
lock file. This ensures all potential changes that would be required of
the `BuildPlan` are caught. It also allows us to provide a "Cause" for
*why* the lock file would need updating when `--locked` is passed to
prevent it.

Closes #2084
Closes #2085

* Add conceptual distinction between replacing `TypeInfo::Self` and monomorphization (#2017)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Add `abi` handling to `sway-fmt-v2` (#2044)

* Refactor `forc_pkg::BuildConfig` -> `BuildProfile`, fix CLI arg handling (#2094)

Previously, if any of the `print` args were set, the rest of the
selected build profile was ignored. This changes the behaviour so that
the command line arguments only override their associated build profile
fields.

Also renames `BuildConfig` to `BuildProfile` and moves it from
`forc_pkg::pkg` to `forc_pkg::manifest` along with the rest of the
serializable manifest types.

* Update all the E2E should_fail tests to verify their output. (#2082)

Using the `FileCheck` crate it can now pattern match against the
compiler output to be sure the errors and/or warnings are exactly what
we expect.

* forc: Improve the `print_*_asm` CLI option docs (#2095)

Previously, these implied no bytecode was generated if the flag was not
set, however this is not the case.

* update fuelup related instructions (#2099)

* update fuelup instructions

* better instructions

* better wording for modifying path

* Adding `--time-phases` to `forc build` (#2091)

* make items under [project] ordered alphabetically in forc.toml

* issue #1893store/show bytecode hash

* formatted

* added cargo lock file

* cargo toml dependencies in alphabetical order

* hash bin of script or predicate only

* format

* generating bytecode hash only on scripts and predicates

* removed option from Compiled::tree_type

* ran clippy

* added to forc_build documentation

* made filename suffix containing bin hash a constant

* get root of predicate bytecode

* Apply suggestions from code review

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* if let to match on program type

* Update forc/src/cli/commands/build.rs

updating bin-root filename

Co-authored-by: mitchmindtree <mail@mitchellnordine.com>

* added benchmarks for compilation process

* use macro instead of closure for wrapping parts of compilation process

Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: Toby Hutton <toby@grusly.com>

* Add forc feature for overriding packages in the package graph, akin to cargo's [patch] feature (#1836)

* Bump to v0.16.2 (#2105)

* bump to v0.16.2

* Fix one test not pointing to local std

* Add struct formatting to sway-fmt-v2 (#2058)

* internal: Reduce amount of String::new() in sway-fmt-v2 (#2111)

* examples: fix renaming to BASE_ASSET_ID in comment (#2120)

* Added storage field alignment threshold to formatter config (#2113)

* Enable storage initializers and emit a storage initialization JSON (#2078)

* Enable storage initializers and dump out a JSON file

* Move the new functions into a separate storage module

* Use StorageSlot directly from fuel-tx

* forc deploy now uses the storage slots

* add some tests

* lint, change initializers -> slots, and fixing some tests

* enhance a comment

* Revert unneeded changes to sway-types

* add a failing test

* Fix failing test

* renaming some functions

* Test the storage slots JSON in e2e tests and add forc json-storage-slots command

* ignore *_output.json

* forc documenter changes

* Remove forc json-storage-slots and stop relying on forc json-abi

* Enhance some comments

* Remove unnecessary oracle

* Improve reserved keywords checking and add support for raw identifiers. (#2066)

Add support for raw identifiers and improve reserved keywords checking.

This commit deals with the usage and checking of reserved keywords
as identifiers, for code like:

```
fn main() {
    let mut mut = 0;
}

It introduces a new error that checks if an identifier is a reserved
keyword:

```
error
 --> /main.sw:4:13
  |
2 |
3 | fn main() {
4 |     let mut mut = 0;
  |             ^^^ Identifiers cannot be a reserved keyword.
5 | }
  |
____
```

There was an existing issue in the standard library, which
has a library/module named `storage`.

Instead of working around this by renaming it to something else,
an alternative solution with raw identifiers is implemented.

This raw identifier feature is implemented at the lexer level,
and allows you to use keywords as identifiers in places that
generally wouldn't be allowed.

Rust and a bunch of other modern languages also provide this escape
hatch, and it seemed the simplest solution for me to handle the issue.

It activates by declaring an identifier prefixed with `r#`, just like
Rust.

The complexity on the codebase to support this feature is pretty
minimal, but if there any objections to this, I can easily remove it,
but some other solution to the issue above will need to be figured out.

Closes #1996.

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* remove `fuels-abigen-macro` dependency (#2007)

* add remove fuels-abigen-macro dependency

* add change dep. versions

* add fuel 0.16

* add fuel-core-lib flag

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add fuel-core-lib flag fix

* add remove -- form forc test command

* add replace constants

* add expand CI command

* add fix tests

* add fix tests

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update test/src/sdk-harness/Cargo.toml

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* add return -- cmd

* add remove fuels-abigen-macro from tests

* add remove fuel-core-lib flag

* add fuel-core-lib flag

* add reverte CI file

* add remove features

* add remove [features]

* add merge master

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Adds `Generics` handling to `sway-fmt-v2` (#2110)

* #2020 - changed BASE_ASSET_ID type to ContractId (#2137)

* #2020 - changed BASE_ASSET_ID type to ContractId

* Fix identity example

* Changes after review

* #2039 - add storage keyword highlighting in book (#2141)

* #2039 - add storage keyword highlighting in book

* Changes after review

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Add the U256 type (#2103)

* feat: add new bare u256 module to std

* feat: Add base type + from,into traits

* test: setup testing for U256

* cleanup

* feat: add impl U256 max, min, bits, new

* test: add new test assertions

* style: fmt

* test: generate oracle file

* Update sway-lib-std/src/u256.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* fix: remove * import

* fix: improve error handling

* test: better test coverage

* style: fmt

* docs: add test comments

* test: add more test cases for to_u64()

* fix: remove #r prefix from storage lib

* test: remove redundant test

* refactor: rename to_u64 to as_u64

* Revert "fix: remove #r prefix from storage lib"

This reverts commit 8dd0738.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* sway-fmt-v2 formatting should use tokens directly from sway-parse (#2097)

* Move monomorphization conceptually inside of the type engine (#2093)

* Do not rely on TypeMapping when type checking declarations.

* Prevent leaking types in impls.

* Prevent unconstrained type parameters.

* WIP

* clippy

* WIP

* Use TypeId in TypeMapping and in TraitMap.

* Add semantic type constraints.

* Update test case.

* fix

* Use TypeId inside of resolve_type_with_self and resolve_type_without_self.

* clippy

* X

* Remove self_type from monomorphization.

* Add conceptual distinction between replacing TypeInfo::Self and monomorphization.

* Bug is fixed.

* Add forc.lock.

* update

* Move test to inside of the SDK.

* Fix test cases.

* Add lock files.

* Fix test.

* Move the stuff.

* Move monomorphization conceptually inside of the type engine.

* Remove commented out test.

* `forc-pkg` - Don't add transitive deps (besides `core`) to a package's initial namespace (#2136)

`forc-pkg` - Don't add transitive deps (besides `core`) to namespace

Currently `forc-pkg` adds all transitive dependencies to a package's
initial namespace prior to its compilation. This had the benefit of
implicitly including `core`, but with the downside of implicitly
including every other transitive dependency package, even if not a
direct depednency (not what we want).

This PR changes the behaviour to only include direct dependencies and
`core` within a package's initial namespace.

Addresses 1, 2 of #2125.

* Demonstrate that `T` for `Vec` can now be inferred by arguments (#2132)

The bug is fixed.

* Remove unnecessary "core" str check in `Span::join` (#2156)

* Update the book to explicitly mention that `impl` functions can't call each other yet. (#2160)

* Remove duplicate CI checks that already have dedicated jobs (#2161)

I noticed a bunch of our CI jobs were were duplicating existing checks.
In particular, there was a lot of copy-paste steps of installing forc
and the forc-fmt plugin, even when unused in the following checks.

This doesn't improve the real bottleneck (our stdlib test job), but it's
a start.

* Speedup `find_dead_code` pass in control flow analysis (#2159)

Fix slow `find_dead_code` pass in control flow analysis

While waiting for the tests to pass on a PR I thought I'd have a quick
look to see if I could find any quick wins for dead code analysis #1952.

I noticed that that we're using `has_path_connecting` for every
combination of node and entry point. This means we were re-checking the
same nodes many, many times, searching from scratch each time and not
re-using any of the knowledge of already visited nodes in each
consecutive traversal.

This commit refactors the approach to first collect all known live nodes
into a set by traversing from the entry points. We re-use the same `Dfs`
when searching from each entry in order to re-use its inner set of
visited nodes and avoid re-searching sections of the graph that we've
already visited.

The dead nodes are those not contained in the live set after traversal.

This reduces the time taken within the `find_dead_code` call when
building the `std` library in debug from ~7.9 seconds down to ~3.3
milliseconds. 1000x+ speedup in DCA :)

Hopefully this speeds up our CI a bit!

Closes #1952.

* const initialization: a few fixes (#2158)

* const initialization: a few fixes

* cargo fmt

* Address review comments

* Add IR test

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>

* Update broken link for contributing to Sway in README.md (#2172)

Closes #2171

* Backport improvements to `U128` type. (#2169)

* feat: improve U128 type errors & rename to_u264

* test: add tests for renamed as_u64

* Introduce `__eq` intrinsic (#2100)

* Introduce `__eq` intrinsic

* Lower to `Instruction::Cmp` instead of to assembly in IRGen

* Refactor intrinsics to all have arg and type arg vectors

* Improvements around `forc plugins` command (#1969)

Use the full path of the plugin when parsing it for a description.

This avoids the following panic caused by trying to exec an executable
in a sub-folder with a partial path:

```
~/dev/sway/target/debug$ forc plugins
Installed Plugins:
thread 'main' panicked at 'Could not get plugin description.: Os { code:
2, kind: NotFound, message: "No such file or directory" }',
forc/src/cli/commands/plugins.rs:43:10
stack backtrace:
   0: rust_begin_unwind
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::expect
at
/rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
   4: forc::cli::commands::plugins::parse_description_for_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:40:16
   5: forc::cli::commands::plugins::format_print_description
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:81:23
   6: forc::cli::commands::plugins::print_plugin
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:97:5
   7: forc::cli::commands::plugins::exec
at
/home/joao/dev/sway/forc/src/cli/commands/plugins.rs:28:21
```

* Updates `user_def` with `FieldAlignment` & fix corresponding use cases (#2153)

* update user_def with AlignFields & fix corresponding use cases

* rmv unused consts

* update doc comments in ItemEnum

* Add `lex_commented` and `CommentedTokenStream` to `sway_parse` (#2123)

* Add `CommentedTokenStream` to `sway_parse`

This doesn't yet collect any comments, but adds the necessary structure
and attempts to preserve the original API and behaviour where possible.

Collecting of comments to be added in a follow-up commit.

* Collect multi-line comments in CommentedTokenStream

* Collect single-line comments in CommentedTokenStream

* Add token_trees and spanned impls for CommentedTokenStream

* Add Spanned impl for CommentedTokenTree. Add comment lexing test.

* Expose `lex_commented` function from root

* Add CommentedTree and CommentedGroup aliases

* Move CommentedTokenTree impl to better location

* Clean up by using CommentedTree type alias where applicable

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>

* Remove unused field `const_decl_origin` from `TypedVariableDeclaration` (#2181)

Remove unused const_decl_origin from TypedVariableDeclaration

After #2158, constant declartaions use TypedConstantDeclaration
AST node, and hence this field is now useless. It must have been
removed in #2158 itself, but I missed doing that.

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: bing <binggh@proton.me>
Co-authored-by: seem-less <mgirach@gmail.com>
Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: zhou fan <1247714429@qq.com>
Co-authored-by: Hlib Kanunnikov <hlibwondertan@gmail.com>
Co-authored-by: Emir <emirsalkicart@gmail.com>
Co-authored-by: r-sitko <19492095+r-sitko@users.noreply.github.com>
Co-authored-by: Nick Furfaro <nfurfaro33@gmail.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>

* removed unncessary use

* added one test

* deleted all contracts except u8s

* fixed bug in pop

* failing test for some reason

* .

* fixed some brackets

* fixed a mistake of >  where it should be >=

* added 2 remaining tests

* Update test/src/sdk-harness/test_artifacts/storage_vec/svec_u8/Cargo.toml

Co-authored-by: Braqzen <103777923+Braqzen@users.noreply.github.com>

* removed storagevecerrors

* assert was the other way round

* added a variable for repeated code

* merged use

* formatting

* expanded the testing

* rearranged file structure

* cargo fmt

* adjusted assert for removes

* removed non test and shortened the contract code

* added cant_get test

* added a todo

* Improved documentation

* updated tests with preconditional tests

* added initializer

* updated functions with sdk release

* mdae build.sh more generic

* fixed build script

* fix 2 electric boogaloo

* updated remove and insert tests

* added len checks

* FINALLY ADDED TESTS FOR ALL TYPES OMG

* alphabetical order

* cargo fmt + changed the b256 consts

* removed unncessary len checks

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: Cameron Carstens <54727135+bitzoic@users.noreply.github.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Co-authored-by: Chris O'Brien <57543709+eureka-cpu@users.noreply.github.com>
Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: bing <binggh@proton.me>
Co-authored-by: seem-less <mgirach@gmail.com>
Co-authored-by: Waseem G <contact@waseem-g.com>
Co-authored-by: mitchmindtree <mail@mitchellnordine.com>
Co-authored-by: zhou fan <1247714429@qq.com>
Co-authored-by: Hlib Kanunnikov <hlibwondertan@gmail.com>
Co-authored-by: Emir <emirsalkicart@gmail.com>
Co-authored-by: r-sitko <19492095+r-sitko@users.noreply.github.com>
Co-authored-by: Nick Furfaro <nfurfaro33@gmail.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Braqzen <103777923+Braqzen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler General compiler. Should eventually become more specific as the issue is triaged lib: core Core library lib: std Standard library
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants