Commit graph

111 commits

Author SHA1 Message Date
IGI-111
d8cf611840
Bump to v0.43.2 (#4907) 2023-08-03 18:23:32 +02:00
IGI-111
3efc60e22b
Bump to v0.43.0 (#4897) 2023-08-02 22:57:10 +02:00
IGI-111
f48268ea5e
More error handling refactoring (#4895)
## Description
This changes addresses the issues introduced in #4878

The `error_emitted` pattern is replaced by a scoping method on `Handler`
that collects errors within a closure and will error out if new erros
are introduced.

All instances of introducing `ErrorEmitted` as a literal value have now
been replaced by passing arround the receipt of the error emission
through the error representing values. Some types from the AST had to be
moved to `sway-types` to avoid circular dependencies introduced by this
change.

This also repairs some of the discrepancies to emitted warnings
introduced in #4878, as well as rename some of the `Handler` methods.

Fixes #4885
Fixes #4886

## Checklist

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

This PR is part of https://github.com/FuelLabs/sway/pull/4794. It
implements the bare minimum to support `u256` constants across the
stack.

They are represented in sway in hex literals with `u256` suffixes. Hex
without suffix will still be `b256`, for backward compatibility until we
implement `u256` completely. Then we can decide what to do.

There are multiple places in the code that will fail if the literal does
not fit in u64. This will be fixed later in a specific PR for big u256.
Some places have temporary `unwrap()`, that will be removed later. I can
try to remove them now, if necessary.

I am leaving all documentation updates for when everything is
implemented.

## Checklist

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

---------

Co-authored-by: Anton Trunov <anton.a.trunov@gmail.com>
2023-07-31 15:22:01 +01:00
IGI-111
f5f8566e8c
Refactor compiler error handling (#4878)
## Description

Change error handling to use `Handler` instead of the macro based
`CompileResult`.

Fix #2734

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-07-29 15:19:59 +00:00
Kaya Gökalp
3b66f8e424
chore: bump to v0.42.1 (#4767)
## Description
release: v0.42.1 version.
2023-07-07 10:55:59 +00:00
Kaya Gökalp
c4e4ef7e4a
chore: bump to v0.42.0 (#4755)
## Description
Also runs `cargo update` in order to update deps to their latest patch
release as this is a breaking release.
2023-07-06 11:26:02 +00:00
IGI-111
e08fab1852
Bump to v0.41.0 (#4720) 2023-06-29 19:26:23 +01:00
mitchmindtree
96c6103541
feature(forc-pkg): Support IPFS-sourced dependencies (#4299)
## Description
Closes #3926.

(edited by @kayagokalp to reflect latest status of the PR)

This PR adds IPFS support for forc-pkg. To do so, forc relies on
existing ipfs local node without embedding a node to forc itself. If
local system does not have an ipfs node running, a public gateway
(https://ipfs.io) is used as a fallback mechanism and packages are
fetched through that.

## Some Context and Future Work

For our package registry stuff to work properly we will eventually need
to host an IPFS node to make sure that our published packages are pinned
by at least one node in the network. That is the case as long as we
don't have a way to incentivize people pinning the packages they
published. What will happen is that a package will be published by a
developer and after we detect the published package our own IPFS node
will pin it to make sure it is always accessible.

Also some benchmarks are done for public gateway during development. It
looks like for initial fetch operations from public gateway spends some
time looking for the package pinned by the IPFS node simulating our
incoming fuel IPFS node which is explained above. It is manageable but
fetching from the fuel IPFS node is instant as it already got the
package pinned. We can consider falling back to our own node's gateway
api rather than a public one to smooth the process.

Finally maybe we can explore embedded ipfs node option as a follow-up,
due to the status of IPFS with Rust, it is not very obvious (maybe not
event possible atm) how to be able to be fully compatible with kubo, for
fetching/publishing our packages. But this is still an open question
worth exploring.

## Testing

### To test with a local node:

1. You can install kubo, you can follow the instructions in their
website while installing https://docs.ipfs.tech/install/command-line/
2. Run the `ipfs daemon` service with `ipfs daemon`
3. Add an ipfs source, I have a package already pinned by my IPFS node
that you can use:
```toml
[dependencies]
test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" }
```
4. Run `forc build`

### To test public gateway fallback:

1. Either do this before starting `ipfs daemon` or stop your local
daemon with `ipfs shutdown`.
Add an ipfs source, I have a package already pinned by my IPFS node that
you can use:
```toml
[dependencies]
test_lib = { ipfs = "QmfZ3uH7dFEDkYN5RQfyu4m7L8uk8kGiLkNwzHqsrormSj" }
```
2. Run `forc build`


---------

Co-authored-by: kayagokalp <kaya.gokalp@fuel.sh>
2023-06-19 23:35:44 +00:00
Sophie Dankel
38a2b55991
LSP: generate doc comments for trait functions (#4665)
## Description

Closes https://github.com/FuelLabs/sway/issues/4645

This PR lets the user generate doc comments for ABI methods. Previously
it was working for functions and function implementations of ABI/trait,
but not on the ABI/trait definition itself.

Since the output is exactly the same for FunctionDecl to TraitFn, I
wanted to do this in a way where they could share the code. I ended up
writing a trait called `FunctionSignature` that both types implement
that exposes `parameters()` and `return_type()`. This allows me to use
the same code for code actions and I suspect it will come in handy in
the future.

One problem was that `FunctionDecl`'s return_type was `TypeArgument`
while `TraitFn` had its return type as `TypeId` with an additional
`return_type_span` field. I changed it so that `TraitFn`'s return_type
is now `TypeArgument` and removed `return_type_span`.

I also needed to add a `span` field to `TraitFn` since previously its
`span()` was returning only the span of the function name, not the whole
function. From what I could see, this doesn't impact the spans of any
existing errors.

### Testing

I added an integration test to the LSP for this scenario.

### Example

![Jun-13-2023
14-40-21](5ba750b6-9f9d-4cb9-96a8-c791bf93b77d)

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-06-15 19:30:38 +02:00
IGI-111
d5464e07a8
Simplify the lifetimes around engines (#4629)
## Description
Inspired by #4588

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-06-05 14:03:59 +01:00
Chris-san
545d7c4f44
fix: replace recursive build strategy with BuildPlan compilation order (#4616)
## Description
Closes #4604 

fixes the redundant re-building of dependencies by using the
`BuildPlan`s compilation order
2023-06-02 17:20:49 +10:00
IGI-111
d026ddb8c2
Bump to v0.40.1 (#4614) 2023-05-31 15:13:02 +00:00
Kaya Gökalp
164c7c8bea
release: bump to v0.40.0 (#4601)
## Description

Waiting for:
- #4525.

@Dhaiwat10 was waiting for a release with the linked PR merged.

@IGI-111 I had the PR ready, leaving it up to you when to merge & cut
the release. Made this a major bump as we had a breaking change merged
(#4574).

## Checklist

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

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2023-05-31 10:21:28 +00:00
IGI-111
161ae35714
Stabilize module privacy (#4574)
## Description

Set experimental module privacy rules as the default and remove the
experimental flag.
Closes #4506 

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-05-25 11:25:08 +02:00
IGI-111
e3065657c9
Bump to v0.39.1 (#4585) 2023-05-24 13:22:42 +00:00
João Matos
dc67807a22
Refactor existing code to use engines and add a new query engine. (#4575)
## Description

As title says, this refactor existing code to pass the engines type to
more places, and adds a new query engine while at it.

The query engine in this form still does not do anything at all, but
will be populated next with the necessary bits for its purpose.

## Checklist

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

Generates the documentation for dependencies & small improvements to the
API.

These changes **DO NOT** create links between dependency docs and the main docs, but generates the dependency docs and ensures there are no conflicts when generating these docs.

What's new so far:
- [x] Programs get their own folders, just like `cargo doc`
- [x] Generates documentation for dependencies by default: Closes #4533 
- [x] Fixes possible conflict with `assets` folder: Closes #4545 
- [x] Removes old docs before generating new ones: Closes #4544 

## Checklist

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

---------

Co-authored-by: Chris O'Brien <eureka@noctua.attlocal.net>
2023-05-22 21:27:32 +03:00
IGI-111
7a095280e7
Bump to 0.39.0 (#4568) 2023-05-17 15:48:16 +02:00
Chris-san
bbe746dafa
feat(forc doc): Add impl_trait representation to ItemBody (#4389)
## Description
Adds a trait implementation section to item declarations & fixes CSS for
required methods on traits.



https://user-images.githubusercontent.com/57543709/236067329-11bb66bd-b7b9-4a46-81d6-520d0e2ece83.mov



## Checklist

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

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-05-04 10:18:26 -05:00
IGI-111
1ecc5e79d6
Implement module privacy rules (#4474)
## Description

This change mainly adds checks to enforce the new module privacy rules
and supporting changes for it.

Changes include updating std and core to use
public modules, updating the parser to allow the use of the `pub mod`
syntax and adding an error type for private modules.

This change is implemented behind a `--experimental-private-modules`
experimental flag and not enabled by default.

It implements part of https://github.com/FuelLabs/sway/issues/4446, the
`pub use` syntax is yet to be implemented.

## Checklist

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

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-04-28 10:30:53 +01:00
mitchmindtree
2d16d70ab9
Re-publish 0.37.2 as 0.38.0 due to breaking changes (#4494)
See here for context:
https://github.com/FuelLabs/sway/pull/4492#issuecomment-1520949069

This follows a re-release of 0.37.1 as 0.37.3:
https://github.com/FuelLabs/sway/releases/tag/v0.37.3

The outcome of all this is that ideally, users previously on 0.37.1 will
now pull 0.37.3 next time they run `cargo update` and will not encounter
any breakage. Those ready to update can point to 0.38.0 after this is
published.

Also runs `cargo update` in order to update deps to their latest patch
release.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-04-25 03:53:15 +00:00
Kaya Gökalp
dc6af91393
Bump to v0.37.2 (#4492) 2023-04-24 22:19:25 +02:00
sarahschwartz
3334843ab4
fix: forc-doc links sort order (#4475)
close #3995 

Fixes shallow alphabetization for the all doc items.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-04-21 00:16:40 +00:00
sarahschwartz
532dc44587
Sort forc-doc links alphabetically, add std-lib docs definitions (#4465)
## Description

This PR sorts forc doc links in alphabetical order and adds some missing
definitions to the std-lib docs.

Close #3995 

## Checklist

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

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-04-19 15:13:30 -06:00
Joshua Batty
7011edd02e
Refactor TyDecl Enum and Separate Structs for Improved Code Organization (#4457)
## Description
This PR refactors the `TyDecl` enum by separating its variants into
individual structs and simplifying the enum itself, leading to better
code organization and maintainability.

This refactoring enhances modularity making it easier to implement a
Parse trait on these types in the language server when matching on the
variants during AST traversal, which is required to unblock #3799. I had
attempted to do this in #4247 but it was reverted by @emilyaherbert.
Hopefully, this new approach is acceptable.

The main change is

```rust
#[derive(Clone, Debug)]
pub enum TyDecl {
    ConstantDecl {
        name: Ident,
        decl_id: DeclId<TyConstantDecl>,
        decl_span: Span,
    },
    FunctionDecl {
        name: Ident,
        decl_id: DeclId<TyFunctionDecl>,
        subst_list: Template<SubstList>,
        decl_span: Span,
    },
    ....
}
```

Has been changed to 

```rust
#[derive(Clone, Debug)]
pub enum TyDecl {
    ConstantDecl(ConstantDecl),
    FunctionDecl(FunctionDecl),
    ....
}

#[derive(Clone, Debug)]
pub struct ConstantDecl {
    pub name: Ident,
    pub decl_id: DeclId<TyConstantDecl>,
    pub decl_span: Span,
}

#[derive(Clone, Debug)]
pub struct FunctionDecl {
    pub name: Ident,
    pub decl_id: DeclId<TyFunctionDecl>,
    pub subst_list: Template<SubstList>,
    pub decl_span: Span,
}
```

## Checklist

- [x] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-04-18 23:13:48 +10:00
sarahschwartz
abddf73212
refactor: forc-doc- move headers above descriptions and add extra vertical spacing between items (#4433)
close #4432

<img width="1227" alt="forc-doc-updates"
src="https://user-images.githubusercontent.com/58856580/231614340-9f931dbb-7647-4c84-8a20-9e6b56f3346c.png">

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-04-17 08:47:15 -06:00
Mohammad Fawaz
83e5479462
Bump to v0.37.1 (#4435) 2023-04-13 12:28:13 -04:00
Mohammad Yasir
800089eb62
Updated the sway.js file by adding mod and type in keyword (#4427)
## Description
fixes #4424 
closes #4424 


## Checklist

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

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-04-12 22:39:45 +00:00
Mohammad Fawaz
607ac50176
Bump to v0.37.0 (#4401) 2023-04-05 20:01:56 -04:00
Mohammad Fawaz
92818a4d5e
Bump to v0.36.1 (#4397) 2023-04-05 10:04:12 -04:00
Mohammad Fawaz
77f575ab79
Bump to v0.36.0 (#4388)
Also ran `cargo update` because this is a breaking release.

Pending:
- [x] https://github.com/FuelLabs/sway/pull/4391
- [x] https://github.com/FuelLabs/sway/pull/4390
- [x] https://github.com/FuelLabs/sway/pull/4385
2023-04-04 22:25:46 -04:00
Chris-san
085175a7a4
chore(forc-doc): Reorganizes the file tree (#4382)
## Description
Just a clean up PR to make finding & understanding things much easier.

## Checklist

- [x] I have linked to any relevant issues. #3656 #3659
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-04-03 00:13:37 +00:00
Chris-san
95cb67d691
Add support for nested submodules to forc doc (#4333)
## Description
Sort of hacky, but this PR fixes the support for nested submodules. I've
opened #4371 as a follow up to fix this. It also fixes a bug I found
while working on this, which was merging modules of the same name, even
if they were in different folders.

[Screencast from 2023-03-28
17-44-07.webm](https://user-images.githubusercontent.com/57543709/228384162-f94249db-66d8-42dd-9c77-33a31b633a8b.webm)

## Checklist

- [x] I have linked to any relevant issues. Closes #3929 Closes #4370 
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-04-01 03:14:38 +00:00
Emily Herbert
31dc809fe0
Rename Declaration to Decl in a number of places. (#4324)
## Description

Some function signatures are beginning to get rather unwieldy with the
introduction of new traits, impl blocks for types with nested type
arguments, etc.

This change canonicalizes the name "declaration" to "decl". "decl" was
already being used in the `DeclEngine`, and now "decl" is used elsewhere
as well. This change will allow for more simple formatting from `cargo
fmt` and function signatures that are easier to read.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-03-23 18:46:01 -04:00
JC
169ad0b145
Cleanup TOMLs (#4312)
Moves following `Cargo.toml` fields to workspace `Cargo.toml` so we
don't have to keep repeating ourselves:

- edition
- authors
- homepage
- license
- repository
2023-03-20 16:22:12 +00:00
João Matos
ee0a0fd9ea
Implement parsing and semantic analysis for associated consts (#4262)
## Description

This splits off the parsing and semantic analysis changes out of
https://github.com/FuelLabs/sway/pull/4036 into a bunch of commits:

[Implement associated constants in traits and
ABIs.](c333b4d740)

[Added multiple definition error name checking to
traits.](88dc9d1430)

[Refactor namespace method resolving code to be
item-based.](5d2eb6f177)

[Add constants to the trait namespace and map to allow referencing from
methods](d4c48f7210)

This one adds a bunch of disabled tests, next PR will enable them with
corresponding IR generation changes and docs.

Related to https://github.com/FuelLabs/sway/issues/3797.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-03-15 09:24:13 -04:00
JC
7f043342ff
Improve attribute parsing (#4134) 2023-03-13 18:04:59 +00:00
Emily Herbert
9934103647
Slightly improve the DeclRef API and interface. (#4258)
## Description

This PR adds a couple impl blocks for `From` to improve the `DeclRef`
API and interface.

## Checklist

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

Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
2023-03-10 19:09:44 +00:00
Emily Herbert
4c1c1d8b95
Use DeclId directly for TyDeclaration::StructDeclaration and TyDeclaration::EnumDeclaration. (#4251)
## Description

This PR fixes a regression to `TyDeclaration::StructDeclaration` and
`TyDeclaration::EnumDeclaration` and removes the `DeclRef`s that they
were holding.

## Checklist

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

---------

Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
2023-03-10 12:59:16 -05:00
AndrésF
63382365bd
doc: Adding annotations support on highlight.js (#4186)
## Description

resolves #2740
closes #4157

> In order to give a better highlighting I picked the "meta" scope as
seen in [highlight.js
docs](https://highlightjs.readthedocs.io/en/latest/css-classes-reference.html)
> 
> The ["Mode"
](https://highlightjs.readthedocs.io/en/latest/language-guide.html) I've
added provides the html class: _hljs-meta_ however, the result is a
white color for annotation (like plain text) and not a blue color as
requested in the issue.
> 
> The solution I've found for this is to add an additional css file to
specify custom behavior for the desired class. I haven't added this file
because I think it's out of scope.


## Checklist

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

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2023-03-10 15:24:50 +00:00
Mohammad Fawaz
d735e99f28
Introduce CallPath to TyConstantDeclaration (#4219) 2023-03-09 18:38:54 -05:00
Emily Herbert
a666f0a9bf
Revert "Change some TyDeclaration variants to hold decl refs" (#4252)
Reverts FuelLabs/sway#4247
2023-03-10 07:37:46 +11:00
Joshua Batty
a0ce83cc52
Change some TyDeclaration variants to hold decl refs (#4247)
## Description
I noticed that out of the variants in `TyDeclaration`, only
`StructDeclaration` and `EnumDeclaration` were wrapping the new
`DeclRef..` types introduced in #4181. This PR simply adds them to the
other variants.

My motivation is so I can implement a Parse trait on these types in the
language server when matching on the variants during AST traversal.

## Checklist

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

Implement RFC 0006, fix #4191.

Remove the `dep` reseved keyword in favor of `mod`.

Change path resolution for submodules to use an adjascent file at the
root and a folder named after the current module in other cases.

Remove the need for an argument to `library`, the LSP now points to
empty spans at the top of module files.

The library names are now determined by the file name, or the package
name at the top level.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-03-09 19:14:52 +11:00
Chris O'Brien
eac5a0a66e
Improve forc doc navigation interface (#4212)
## Description

Changes the path to the root when clicking the Sway logo. Adds some nice
CSS for the button that navigates to the `all doc`, and adds links to
each parent module in a `CallPath`.

[Screencast from 2023-03-07
17-20-16.webm](https://user-images.githubusercontent.com/57543709/223628980-855d29dd-029f-440e-89e2-96f8484741a9.webm)



## Checklist

- [x] I have linked to any relevant issues. 
    Closes #3996 
    Closes #4195 
    Closes #4197 
    Closes #4196 
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-03-09 01:58:24 +00:00
Mohammad Fawaz
49eae2dd93
Bump to v0.35.5 (#4242) 2023-03-08 13:12:24 -05:00
Mohammad Fawaz
3770dd8c21
bump to v0.35.4 (#4230) 2023-03-07 14:38:24 +00:00
Chris O'Brien
276ef415b2
Add links for types that go to their definitions (#4017)
This is nearly complete, but there are a few things I need to address
before this can go through: #4021 (ref #3744) & #4018

Closes #3173 

[Screencast from 2023-02-13
12-32-28.webm](https://user-images.githubusercontent.com/57543709/218544317-00634be0-86de-4e0c-b2fc-97ef9f00c41a.webm)

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-03-04 15:18:50 -06:00
IGI-111
8be626aa94
Use DeclRef for struct and enum TypeInfo (#4213)
## Description

Use references and the decl engine to resolve information about structs
and enums instead of copying around declaration data.

This should facilitate #3744

## Checklist

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