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

Result instantiation produces suboptimal warnings #3584

Closed
tritao opened this issue Dec 13, 2022 · 1 comment · Fixed by #4421
Closed

Result instantiation produces suboptimal warnings #3584

tritao opened this issue Dec 13, 2022 · 1 comment · Fixed by #4421
Assignees
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged DCA Everything to do with Dead Code Analysis enhancement New feature or request

Comments

@tritao
Copy link
Contributor

tritao commented Dec 13, 2022

Take the following code:

script;

use std::result::*;

fn main() {
    let a: Result<u32, u8> = Result::Ok(5);
}

Produces the following warnings which don't point to the actual problem and seemingly related to the same issue but duplicated pointing to different locations.

  Compiled library "std".
warning
  --> /home/joao/dev/sway/sway-lib-std/src/result.sw:15:5
   |
13 | 
14 |     /// Contains the success value
15 |     Ok: T,
   |     ----- This cast, from integer type of width sixty four to integer type of width thirty two, will lose precision.
16 |     /// Contains the error value
17 |     Err: E,
   |
____

warning
  --> /home/joao/dev/sway/sway-lib-std/src/result.sw:13:17
   |
11 | 
12 | /// ([`Err`]).
13 | pub enum Result<T, E> {
   |                 - This cast, from integer type of width sixty four to integer type of width thirty two, will lose precision.
14 |     /// Contains the success value
15 |     Ok: T,
   |
____
@tritao tritao added bug Something isn't working enhancement New feature or request compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Dec 13, 2022
@otrho
Copy link
Contributor

otrho commented Dec 14, 2022

This is related to #3470 and assuming prematurely that a Numeric is a u64.

Also similar to #606

@mohammadfawaz mohammadfawaz added the DCA Everything to do with Dead Code Analysis label Feb 13, 2023
@esdrubal esdrubal self-assigned this Apr 10, 2023
esdrubal added a commit that referenced this issue Apr 10, 2023
Enums and structs unify warning messages were pointing to the declared types.

With these changes the warning messages now point to the place of usage span.

Closes #3584
tritao pushed a commit that referenced this issue Apr 10, 2023
## Description

Enums and structs unify warning messages were pointing to the declared
types.

With these changes the warning messages now point to the place of usage
span.

Closes #3584

## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged DCA Everything to do with Dead Code Analysis enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants