You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix and improve errors when the entry fns cannot be generated (#5824)
## Description
This PR improves fix a problem when a type cannot be auto-impled and
improve error messages for this case.
This can be seen on `tests/types/contracts/type_inside_enum` in the Rust
SDK repo.
```
Running `target/debug/forc build --path /home/xunilrj/github/fuels-rs/packages/fuels --experimental-new-encoding`
thread 'main' panicked at sway-ir/src/constant.rs:172:14:
Enums are aggregates.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Given that this PR also improve implementation of arrays for `AbiEncode`
and `AbiDecode`, the entry function is actually generated. But in case
of error, it will fail like:
```
error
--> /home/xunilrj/.forc/git/checkouts/std-9be0d6062747ea7/5645f10143243e1fd64a55002cd5c09730636ece/sway-lib-core/src/codec.sw:2192:8
|
2190 |
2191 | pub trait AbiDecode {
2192 | fn abi_decode(ref mut buffer: BufferReader) -> Self;
| ^^^^^^^^^^ No method named "abi_decode" found for type "SomeEnum".
2193 | }
|
____
error
--> <autogenerated>:5:61
|
3 |
4 | let args: (SomeEnum,) = decode_second_param::<(SomeEnum,)>();
5 | let result_arr_inside_enum: raw_slice = encode::<SomeEnum>(__contract_entry_arr_inside_enum(args.0));
| ^^^^^^^^^^^^^^^^^^ Trait "AbiEncode" is not implemented for type "SomeEnum".
6 | __contract_ret(result_arr_inside_enum.ptr(), result_arr_inside_enum.len::<u8>());
7 | }
|
____
error
--> <autogenerated>:24:61
|
22 |
23 | let args: (SomeEnum,) = decode_second_param::<(SomeEnum,)>();
24 | let result_str_inside_enum: raw_slice = encode::<SomeEnum>(__contract_entry_str_inside_enum(args.0));
| ^^^^^^^^^^^^^^^^^^ Trait "AbiEncode" is not implemented for type "SomeEnum".
25 | __contract_ret(result_str_inside_enum.ptr(), result_str_inside_enum.len::<u8>());
26 | }
|
____
error: Could not generate the entry method because one of the arguments does not implement AbiEncode/AbiDecode
____
Aborting due to 4 errors.
Error: Failed to compile type_inside_enum
````
## 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [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.
0 commit comments