Skip to content

Resolve: incorrect error messages after a duplicate module definition #31644

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
jseyfried opened this issue Feb 13, 2016 · 0 comments · Fixed by #31648
Closed

Resolve: incorrect error messages after a duplicate module definition #31644

jseyfried opened this issue Feb 13, 2016 · 0 comments · Fixed by #31648

Comments

@jseyfried
Copy link
Contributor

For example,

mod foo {
    fn bar() -> bool { bar() }
}

mod foo {
    fn baz() { baz() }
    fn bar() { bar() }
}

reports the duplicate definition of foo, but also reports

<anon>:6:16: 6:19 error: unresolved name `baz` [E0425]
<anon>:6     fn baz() { baz() }
                        ^~~
<anon>:6:16: 6:19 help: see the detailed explanation for E0425
<anon>:7:16: 7:21 error: mismatched types:
 expected `()`,
    found `bool`
(expected (),
    found bool) [E0308]
<anon>:7     fn bar() { bar() }

The example compiles without errors if one of the modules' name is changed.

jseyfried added a commit to jseyfried/rust that referenced this issue Feb 14, 2016
bors added a commit that referenced this issue Feb 15, 2016
This PR fixes two unrelated diagnostics bugs in resolve.

First, it reports privacy errors for an import only after the import resolution is determined, fixing #31402.

Second, it expands the per-module map from block ids to anonymous modules so that it also maps module declarations ids to modules, and it uses this map to in `with_scope` to fix #31644.

r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant