Skip to content

bogus parameter-count error following error in parameter list #34264

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

Closed
durka opened this issue Jun 14, 2016 · 0 comments
Closed

bogus parameter-count error following error in parameter list #34264

durka opened this issue Jun 14, 2016 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@durka
Copy link
Contributor

durka commented Jun 14, 2016

fn foo(Option<i32>) {}

fn main() {
    foo(Some(42));
}

The first error is about the missing argument name in foo's parameter list, but there's another one on the call saying that the function doesn't take any parameters. I guess a dummy item was created to prevent cascading resolve errors, but it seems to create another kind of cascading error.

@apasel422 apasel422 added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 14, 2016
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
bors added a commit that referenced this issue Apr 8, 2017
Introduce `TyErr` independent from `TyInfer`

Add a `TyErr` type to represent unknown types in places where
parse errors have happened, while still able to build the AST.

Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use `TyInfer` for this as
`_` is not allowed as a valid argument type.

Example output:

```rust
error: expected one of `:` or `@`, found `,`
  --> file.rs:12:9
   |
12 | fn bar(x, y: usize) {}
   |         ^

error[E0061]: this function takes 2 parameters but 3 parameters were supplied
  --> file.rs:19:9
   |
12 | fn bar(x, y) {}
   | --------------- defined here
...
19 |     bar(1, 2, 3);
   |         ^^^^^^^ expected 2 parameters
```

Fix #34264.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants