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

expression without assignment is incorrectly typechecked #1933

Closed
ghost opened this issue Jul 14, 2023 · 2 comments · Fixed by #1960
Closed

expression without assignment is incorrectly typechecked #1933

ghost opened this issue Jul 14, 2023 · 2 comments · Fixed by #1960
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jul 14, 2023

Aim

fn test() {
    1;
    2;
}

Expected Behavior

the compiler doesn't error.

Bug

error: Expected type (), found type Field
   ┌─ src/main.nr:23:5
   │
23 │     1;
   │     -

Error: Aborting due to 1 previous error

To Reproduce

Installation Method

Compiled from source

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@ghost ghost added the bug Something isn't working label Jul 14, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 14, 2023
@ghost
Copy link
Author

ghost commented Jul 14, 2023

and another case

fn test() {
    let a: () = {};
}
error: Expected type (), found type ()
   ┌─ src/main.nr:23:17
   │
23 │     let a: () = {};
   │                 --

@jfecher
Copy link
Contributor

jfecher commented Jul 17, 2023

The first case with:

error: Expected type (), found type Field
   ┌─ src/main.nr:23:5
   │
23 │     1;
   │     -

Is expected since you're sequencing an expression without using its result. Perhaps it can be downgraded into a warning though.

The second case with Expected type (), found type () is definitely a bug.

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
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant