Commit graph

278 commits

Author SHA1 Message Date
Mohammad Fawaz
b9996f1346
Bump to v0.32.2 (#3618)
Mainly to get
efd4518b6d
out as per the SDK team's request.
2022-12-15 22:04:28 -05:00
Anton Trunov
5b35baa4cf
Allow comma-separated annotations: #[ann1, ann2, ...] (#3469)
close #3452
close #3475
2022-12-15 09:53:45 +04:00
Mohammad Fawaz
50c1b6c858
Bump to v0.32.1 (#3606)
Mainly to include https://github.com/FuelLabs/sway/pull/3605 so that we
can publish correctly.
2022-12-14 21:59:46 -05:00
Mohammad Fawaz
5bd25b8611
Bump to v0.32.0 (#3602)
- Bump to `v0.32.0`
- Run `cargo update`
- Bump `fuel-core` CI to `0.15.1` since `cargo update` updated `the
`fuel-core` version in `Cargo.lock`.
2022-12-14 16:42:16 -05:00
Emily Herbert
12ad842381
Bump to v0.31.3 (#3479)
Co-authored-by: emilyaherbert <emily.herbert@fuel.sh>
2022-11-30 14:57:21 -06:00
Chris O'Brien
4b6f6d5409
Add code block formatting to forc doc (#3435)
This PR adds a formatting step to documentable code blocks which also
removes user comments. So something like
```rust
pub   struct    Hello     { \n\n
      // hello, a comment good sir
    my_field : u32, // another unwanted comment
    // oops this is a comment
        my_other_field: u32 ,
 }
```

will get formatting and have its comments removed only for the main code
block show casing the `struct`.

Along the way, I found a small problem in `sway_parse` in `item_struct`.
Looks like the parser was looking for the `struct` keyword first instead
of the `pub` keyword. I just added a `let` binding for the visibility
keyword before we check for `struct`.
2022-11-30 03:30:31 +00:00
Mohammad Fawaz
12239f7d57
Bump to v0.31.2 (#3461) 2022-11-29 11:59:43 -05:00
Mazdak Farrokhzad
fe6b76e2c4
Nix the global TYPE_ENGINE (#3353) 2022-11-22 18:06:39 +00:00
Mohammad Fawaz
c32b0759d2
Bump to v0.31.1 (#3352)
Waiting on:
- [x] https://github.com/FuelLabs/sway/pull/3343
2022-11-11 20:55:57 -05:00
Marcos Henrich
ed325d6f11
Adds error for doc comment before Dependency. (#3215)
Before this fix the error message for doc comments before a dep was out
of place and was "Expected an item."

This was fixed by peeking for one or more `DocComment` followed by a
`DepToken` and returning an error in that case. This ensures that no
`DocComment` is consumed and can therefore be consumed later on while
parsing `Annotated<ItemKind>`.

Closes #3116

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: João Matos <joao@tritao.eu>
2022-11-12 00:51:36 +00:00
Mohammad Fawaz
7a389ddb35
Bump tov0.31.0 (#3335)
Also ran `cargo update`

Co-authored-by: Voxelot <brandonkite92@gmail.com>
2022-11-09 19:32:10 -05:00
Mohammad Fawaz
7db4fed89b
Disallow control flow opcodes in asm blocks (#3279) 2022-11-07 04:52:48 +00:00
Mohammad Fawaz
852bef4b54
VM instructions cleanup in the compiler and exposing scwq (#3273) 2022-11-06 01:34:17 +00:00
Mohammad Fawaz
158f22115b
Bump to v0.30.1 (#3290)
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
2022-11-04 14:28:28 -07:00
Mohammad Fawaz
37deaee8fc
Bump to v0.30.0 (#3249)
Also ran `cargo update` as this is a minor release.
2022-11-02 15:40:29 -04:00
Mohammad Fawaz
b83ad9bd85
Disallow assigning to initialized registers in asm blocks (#3239)
Closes https://github.com/FuelLabs/sway/issues/3155

This is needed due to `mem2reg` and some unclear semantics around
initialized registers being passed as ref/mut ref. Besides, it's a good
idea to restrict `asm` blocks as much as possible to avoid weird
unwanted behavior.

<img width="883" alt="image"
src="https://user-images.githubusercontent.com/59666792/199332120-974d1821-680e-43a1-922d-1a32d491b3cd.png">

* I also removed the `disallow_opcodes` check because the parser takes
care of that now. The parser only allows legal opcodes in `asm` blocks.
* Finally, I update the parser to accept the correct storage opcodes
with `fuel-core 0.13` and updates all the tests.

Co-authored-by: Vaivaswatha N <vaivaswatha@users.noreply.github.com>
2022-11-02 16:23:39 +00:00
Alex Hansen
dc8e5f6b84
v0.29.0 (#3222)
Lots of breaking changes. Will go in after:
- [x] https://github.com/FuelLabs/sway/pull/3218
- [x] https://github.com/FuelLabs/sway/pull/3223
2022-10-31 21:13:49 +00:00
Mazdak Farrokhzad
cd100147ab
Eliminate need for ~ in ~Foo::bar() (#3218)
Fixes https://github.com/FuelLabs/sway/issues/1436.

This PR first removes the need for `~` in `~Foo::bar` by first delaying
the interpretation of `Foo::Bar` (associated call, free function call,
or enum variant construction?) until type checking. This is achieved
with `ExprKind::AmbiguousPathExpression`. During type checking, we ask
whether `Foo` (and any prefixes) is a module, or an enum. If it's
neither, we attempt type checking as an associated function call.
Otherwise, we continue as if we had a `ExpressionKind::DelineatedPath`.

Once `~` is made redundant, it's then also removed from the language and
so also from tests, examples, and the standard library.

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
2022-10-31 19:45:38 +00:00
bing
a9b8bb094c
support ** operator (#3141)
closes #3104 

adds `**` to the list of known tokens in the AST, parse and format the
Pow expression as well.
2022-10-26 00:43:38 +00:00
Mohammad Fawaz
84f9aad376
Bump to v0.28.1 (#3142)
Mainly to publish https://github.com/FuelLabs/sway/pull/3140
2022-10-25 17:31:48 +00:00
Mohammad Fawaz
598bbf6785
Bump to v0.28.0 (#3114) 2022-10-25 17:31:02 +11:00
Toby Hutton
2b8761d1aa
Add support for ASM control flow to/from addresses which don't fit in immediate offsets. (#3109)
- Introduce a new control flow op `LoadLabel` which reads an address
  from the data section.
- Convert `JI`, `JNZI`, `JNEI` and `MoveAddress` to use `LoadLabel` and
  `JMP` or `JNE` when required.
- Introduce a `BLOB` instruction which is for testing purposes only, and
  efficiently & conveniently inserts a raft of `NOOP`s into the binary.
2022-10-24 18:18:42 +00:00
Mohammad Fawaz
40f1e79de0
Bump to v0.27.0 (#3100)
https://github.com/FuelLabs/sway/pull/2909 is technically breaking for
someone previoysly using `not()` directly, so I'm releasing `0.27.0`
instead of `0.26.1`.

Pending:
- [x] https://github.com/FuelLabs/sway/pull/3099
- [x] https://github.com/FuelLabs/sway/pull/3096
- [x] https://github.com/FuelLabs/sway/pull/3091
- [x] https://github.com/FuelLabs/sway/pull/3080
- [x] `cargo update`
2022-10-23 20:30:18 -04:00
Mohammad Fawaz
a2395b4c99
Fix span calculations for errors at the end of a file with no final \n (#3066) 2022-10-18 18:41:58 -04:00
Mazdak Farrokhzad
2dc15b15c3
Handler warnings + misc related simplifications (#2986)
After https://github.com/FuelLabs/sway/pull/2981, which this PR is based
on, we can now add `fn emit_warn` to the `Handler`, which is what this
PR does.

This PR also does some related refactoring, in particular in `swayfmt`.
This is work towards https://github.com/FuelLabs/sway/issues/2734.
2022-10-17 13:16:13 +02:00
Emily Herbert
7f587ec0a7
Parse generic traits. (#3029) 2022-10-16 12:05:16 +11:00
Mohammad Fawaz
f05d7f6416
Bump to v0.26.0 (#3023)
Also run `cargo update`
2022-10-13 13:32:01 -04:00
Mazdak Farrokhzad
2c448d95af
Lexer + Parser recovery & Gathering errors in sway-error (#2891)
This PR achieves a couple of related things.

1. All compiler errors are moved into the common `sway-error` crate. The
`Handler` type is now also moved there, and now uses `CompileError`
instead of `ParseError`. That's also the main goal, to generalize
`Handler` to all sorts of errors, which will help solve
https://github.com/FuelLabs/sway/issues/2734 soon.

2. Using 1, we can now also emit `LexError`s into the `Handler`, so this
enables lexer recovery.

3. Lexer recovery is added for e.g., `42y8`, which fixes
https://github.com/FuelLabs/sway/issues/2865.

4. Lexer recovery is added for `'abc'` char literals, which fixes
https://github.com/FuelLabs/sway/issues/2864. The AST supports them, but
the rest of the compiler does not, so this will be useful later on, but
was good for recovery framework testing.

5. Lexer recovery is added for mismatched open/close delimiters, e.g.,
`fn foo() { )`.

6. Lexer recovery is added for unexpected closing delimiters, e.g., `fn
foo() }`.

7. Lexer recovery is added for unclosed delimiters.

8. Parser recovery is added for `let x =`, which fixes
https://github.com/FuelLabs/sway/issues/2815.

9. Misc lexer refactoring and simplifications are made.
2022-10-10 12:10:54 +02:00
Mazdak Farrokhzad
b6b1432ce7
Support type arguments on methods (#2974)
Fixes https://github.com/FuelLabs/sway/issues/2948.

Now it's possible to write `foo.bar::<Baz>()`.
The parser will also do recovery for `foo.field::<Args>`.

Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-10-10 10:49:16 +02:00
Mohammad Fawaz
dfa6224932
Bump to v0.25.2 (#2973)
Another quick release to publish
https://github.com/FuelLabs/sway/pull/2972 to unblock the SDK team.
Pending
- [x] https://github.com/FuelLabs/sway/pull/2972
2022-10-07 11:20:52 -04:00
Mohammad Fawaz
cc9740bea1
Bump to v0.25.1 (#2959)
Mainly to publish https://github.com/FuelLabs/sway/pull/2947
2022-10-06 11:18:52 -04:00
Mohammad Fawaz
0f84734f6f
Bump to v0.25.0 (#2942)
- Also ran `cargo update`.

Pending:
- [x] https://github.com/FuelLabs/sway/pull/2941
- [x] https://github.com/FuelLabs/sway/pull/2940
- [x] https://github.com/FuelLabs/sway/pull/2890
2022-10-05 15:38:50 -04:00
Mohammad Fawaz
85d4f94835
Introduce a __revert intrinsic a disallow rvrt, ret, and retd in asm blocks (#2890)
Closes https://github.com/FuelLabs/sway/issues/2884

Main changes:
1. Disallowing `rvrt`, `ret`, and `retd` in `asm` blocks.
2. Remove all checks that look for the opcodes above.
3. Add `__revert` intrinsic and make its type `Unknown` for now. It will
be `Never` in the future.
4. Add an IR instruction `revert` with no type. There are still some
things that should be ironed out related to that.

Also closes https://github.com/FuelLabs/sway/issues/2822.

https://github.com/FuelLabs/sway/issues/2876 is not fixed yet though.
This is related to the issues mentioned in (4) above.

Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
2022-10-05 18:12:05 +00:00
Mazdak Farrokhzad
a917c66ff1
Misc simplifications (Lexer + LSP) (#2921)
Extracted from https://github.com/FuelLabs/sway/pull/2891 so this can be
reviewed separately.

This PR contains some basic refactoring.
2022-10-03 23:54:24 +02:00
Mazdak Farrokhzad
15b9d4322f
Simplify and refactor the lexer (#2877)
Some drive-by work made to get a better understanding for
https://github.com/FuelLabs/sway/issues/2815 (doesn't fix the issue,
yet) and other possible lexer improvements.

A bug around lexing of integers specified in octal, was also fixed.

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-09-29 09:48:03 +02:00
Mazdak Farrokhzad
40c708ff2a
Parser: recovery for auto-completion (#2858)
Recovers on `expr.`

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

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2022-09-28 14:52:34 +02:00
Mohammad Fawaz
e695606d88
Bump to v0.24.5 (#2840)
Co-authored-by: Toby Hutton <toby@grusly.com>
2022-09-24 08:22:05 -04:00
Kaya Gökalp
22ba988707
Apply new clippy lints for Rust v1.64 (#2830) 2022-09-22 18:54:35 +00:00
Alex Hansen
c8ce718782
0.24.4 (#2794)
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-09-16 08:43:02 -04:00
Mohammad Fawaz
95cd150cac
Bump to v0.24.3 (#2766)
Bump to v0.24.3
2022-09-12 11:44:19 -04:00
Mazdak Farrokhzad
ff038fbd85
Recover class Foo { .. } as struct (#2751)
* recover 'class Foo { .. }' as struct

* class => struct recovery: tweak wording

Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-09-12 07:02:29 -04:00
Mohammad Fawaz
057e83aee8
Bump to v0.24.2 (#2756)
Bump to v0.24.2

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
2022-09-09 11:57:27 -04:00
Mohammad Fawaz
095bfe0309
Add support for the TIME instruction (#2752)
* Add support for the time instruction

* Add a test

* Add a test

* Address some comments
2022-09-08 17:30:03 -04:00
Mohammad Fawaz
54e1a340e6
Bump to v0.24.1 (#2747)
Bump to 0.24.1
2022-09-07 17:40:03 -04:00
Mohammad Fawaz
8200174bb3
Removing some unnecessary opcodes in the parser (#2735) 2022-09-06 15:10:16 -05:00
Mohammad Fawaz
ea4f1b7885
Bump to v0.24.0 (#2730)
* bump to v0.24.0

* Merge with master
2022-09-06 13:01:12 -04:00
Mohammad Fawaz
b696495c8f
Bump to v0.23.0 (#2703)
bump to 0.23.0

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
2022-09-02 18:20:32 -04:00
Mohammad Fawaz
c486eabc3e
Bump to v0.22.1 (#2685)
bump to v0.22.1
2022-08-31 22:54:46 -04:00
Mohammad Fawaz
6e1fbca21f
Bump to v0.22.0 (#2673)
* Bump to v0.22.0

* Update lock file
2022-08-31 21:49:35 -04:00
Nick Furfaro
11fd90a14d
Refactor std::tx to use gtf intrinsic (#2482)
* feat: add all gtf const values

* cleanup: remove offset consts and doc comments

* refactor: update tx_type()

* refactor: update tx_script_gas_price()

* refactor: update tx_script_gas_limit()

* refactor: update tx_maturity()

* refactor: remove tx_byte_price()

* refactor: update tx_script_length()

* refactor: update tx_script_data_length()

* refactor: update tx_inputs_count()

* refactor: update tx_outputs_count()

* refactor: update tx_witnesses_count()

* refactor: update tx_receipts_root()

* refactor: update tx_script_start_pointer()

* refactor: update tx_script_data_start_pointer()

* refactor: update tx_script_data()

* refactor: update tx_script_bytecode()

* refactor: update tx_input_pointer()

* refactor: update & rename tx_input_type()

* refactor: update tx_input_owner()

* cleanup" remove redundant tx_input_type() function

* refactor: update tx_predicate_data_start_pointer()

* refactor: rename get_predicate_data()

* refactor: update fn predicate_data() to be generic

* feat: add fn tx_coin_predicate_data_start_pointer()

* refactor: update tx_output_pointer()

* refactor: update tx_output_type()

* refactor: remove tx_output_type_from_pointer()

* refactor: update tx_output_amount()

* refactor: update fn tx_id()

* refactor: hardcode index 0 for tx field getters

* fix: refactor predicate_data & fix implementation

* docs: add GTF hex values to function docs

* docs: commment out consts and make into comments

* Revert "docs: commment out consts and make into comments"

This reverts commit bdca7bbf36.

* cleanup

* cleanup: consts

* feat: add witness related functions to tx

* feat: add mod inputs to std

* Docs: Add high level module docs

* refactor: remove unused imports

* refactor: move all input consts to imputs.sw

* refactor: remove input-related stuff from tx.sw

* refactor: move inputs to inputs.sw

* refactor: complete move of inputs

* reafactor: input owner functions

* refactor: move input predicate data func to inputs

* refactor: extract 2 predicate data functions

* feat: add fn input_coin_output_index

* feat: add fn input_coin_amount()

* chore: cleanup

* refactor: switch to using __gtf intrinsic

* fix: update calls to read() with turbofish

* refactor: use read() consistently

* fix: semicolon

* fixup

* refactor: make tx_gas_price() general-purpose

* refactor: use gtf for fn tx_type()

* refactor: make tx_gas_limit() general purpose

* refactor: make tx_maturity() general purpose.

* refactor: make tx_inputs_count() general purpose.

* fix: use correct type for __gtf

* refactor: fix tx_script length to return an option.

* refactor: switch tx_script_data_length() to return option

* refactor: update fn tx_outputs_count() to use gtf

* refactor: make inputs/outputs count fns general

* refactor: update fn tx_receipts_root() return type

* refactor: update fn tx_script_data_start_pointer() return type

* docs: add comments to tx_type()

* chore: cleanup

* feat: make fn tx_input_pointer() general purpose

* fix: add GTF_OUTPUT_TYPE const

* feat: refactor tx_id() to use gtf intrinsic

* feat: refactor fn tx_input_type() to use gtf

* refactor: switch fn tx_input_owner() to use gtf

* refactor: make predicate_data() use gtf intrinsic

* refactor: make tx_output_pointer() general purpose

* refactor: use gtf intrinsic in tx_output_type()

* refactor: update tx_output_amount() to use gtf

* refactor: revert rather than returning None

* feat: add fn tx_witness()

* docs: add notes

* fix: uncomment const GTF_OUTPUT_TYPE

* refactor: change tx_type to return enum

* fixup

* refactor: rename tx_witness to tx_witness_pointer

* refactor: add enum Output and modify tx_output_type

* refactor: complete tx refactor with new enum types

* refactor: update token.sw to handle enum returns from tx.sw

* refactor: update auth.sw to handle enum returns from tx.sw

* fix: update calls to read()

* fix: add get_predicate_data() back

* test: update tx_field tests

* cleanup

* refactor:start to move funcs to inputs module

* refactor: split out all inputs related things

* feat: add outputs module and refactor

* cleanup

* refactor: move & rename tx_outputs_count()

* fix: changes to fix compile errors

* fix: changes to fix compile errors

* fix: update token & auth modules

* fix: cleanup duplicate function

* fix: update read() calls with type annotations

* test: update tests to handles stdlib changes

* chore: update test/ cargo manifest & lock

* chore: update sdk-harness/ cargo manifest & tests

* chore: update forc/ cargo manifest & lock

* chore: update forc-pkg/ & sway-core/ cargo manifests & lock

* chore: update sway-types/ cargo manifest & lock

* chore: update test-sig-gen-util/ cargo manifest & lock

* chore: update fuel-core in ci.yaml

* cleanup: remove x.. opcodes from allocated_ops.rs

* fix: complete removal of X.. opcodes from allocated_ops

* chore: remove X.. opcodes from virtual_ops and mod.rs

* resolve type annotation

* refactor: remove byte_price & static_contracts

* chore: bump fuel-core to 0.10.1 in ci.yml

* fix: trying to update harness.rs in e2e tests

* chore: add builder feature to fuel-tx dep

* test: fix test harness

* style: clippy

* fix: remove X.. opcodes from op_codes.rs

* fix: remove X.. opcodes from sway-parse/op_codes

* fix: remove byte_price from parameters.rs

* chore: commit updated cargo lockfile

* fix: improve fn naming consistency

* test:  set index to 0

* chore: update lockfile

* test: fix tests to work with patched SDK

* chore: restore cargo manifest file to patchless version

* test: update auth testing contract

* test: update tx_fields tests

* chore: patch SDK with local branch

* temp: add logging to repro while-loop bug

* fixup: temp logs

* chore: bump to SDK v0.21

* test: update tests to use new wallet api

* chore: bump forc-util

* chore: fix merge-conflict in cargo.lock

* test: fix some tx_field tests

* cleanup

* test: cleanup tx_output_type test

* Remove unused deps

* Remove more unused deps

* Restore some deps

* Fix can_get_script_start_offset test

* fix get_tx_id test

* fix can_get_tx_output_type test

* Fix can_get_tx_input_coin_owner test

* Disable mint/transfer tests and hopefully resolve the unused deps issue

* Re-enable the token tests as they actually work now with a fix to token.sw

* Some clean up and removing untested functions

* Add some useful comments and return None as the owner of a message input

* remove dead constants

* fmt

* update the lock file

* Update the SDK version for forc new

* cleanup: remove logging from token.sw

* cleanup: remove stale TODO from test

* style: consolidate imports in test file

* Update comments for output_amount to point to a github issue

* Using if let instead of a match statement

* Link to github issue for testing

* Update some constants based on the old spec until the new spec is implemented

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
Co-authored-by: João Matos <joao@tritao.eu>
2022-08-31 12:59:45 +00:00