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

bug: Incorrect diagnostic placement when returning wrong type #6486

Open
piotmag769 opened this issue Oct 15, 2024 · 0 comments
Open

bug: Incorrect diagnostic placement when returning wrong type #6486

piotmag769 opened this issue Oct 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@piotmag769
Copy link
Collaborator

Bug Report

Cairo version:

2.8.2

Current behavior:

fn incorrect_return_type() {
    let x = 5;
    x
}

Diagnostic point to the variable definition and blame the impossibility of casting

error: Mismatched types. The type `()` cannot be created from a numeric literal.
 --> {SOME_PATH}:16:17
        let x = 5;
                ^

Expected behavior:

Imo it should show the actual root cause of the issue. That's how it looks in Rust:

error[E0308]: mismatched types
  --> crates/cairo-lang-language-server/src/lang/diagnostics/mod.rs:98:9
   |
96 |     fn incorrect_return_type() {
   |                               - expected `()` because of default return type
97 |         let x = 5;
98 |         x
   |         ^ expected `()`, found integer
@piotmag769 piotmag769 added the bug Something isn't working label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant