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

Add compiler pass that discovers ambiguous imports #6868

Merged

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented May 26, 2023

Fixes #6431

Pull Request Description

Add a new compiler pass that analyses duplicated and ambiguous symbols from imports. A duplicated import is an import that imports a symbol that has already been imported by a previous import statement and that refers to the same object. An ambiguous import is an import statement that imports a symbol that has already been import by a previous import statement and refers to a different object.

For every ambiguous import, an error is provided - by replacing the IR with the IR.Error. For every duplicated import, a warning is attached to the IR.

Example of the compiler error message:

Extensions.enso[41:1-41:77]: Ambiguous imported symbol 'Codepoint_Ranges' in import statement. The original import is 'import Standard.Base.Data.Text.Text_Sub_Range.Codepoint_Ranges' in Extensions.enso[20:1-20:56]

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@Akirathan Akirathan linked an issue May 26, 2023 that may be closed by this pull request
…rts-not-reported

# Conflicts:
#	engine/runtime/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala
@Akirathan Akirathan self-assigned this May 31, 2023
@Akirathan Akirathan force-pushed the wip/akirathan/6431-ambiguous-aliased-imports-not-reported branch from 6df70b9 to c0611ac Compare June 7, 2023 14:57
@Akirathan Akirathan marked this pull request as ready for review June 7, 2023 15:30
@Akirathan Akirathan force-pushed the wip/akirathan/6431-ambiguous-aliased-imports-not-reported branch from 3e219c3 to 0cca1a6 Compare June 9, 2023 15:25
Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Scala code could be improved.

Comment on lines +232 to +235
) match {
case Left(error) => Left(List(error))
case Right(imp) => Right(imp)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as before

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused. Do you mean the one with fold suggestion? How should I refactor this to fold?

@Akirathan Akirathan force-pushed the wip/akirathan/6431-ambiguous-aliased-imports-not-reported branch from ca9bcc8 to b36b4b8 Compare June 9, 2023 16:14
@jdunkerley
Copy link
Member

Thanks for the changes looks much cleaner.

@Akirathan Akirathan removed the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Jun 14, 2023
@Akirathan Akirathan merged commit 67821bf into develop Jun 14, 2023
@Akirathan Akirathan deleted the wip/akirathan/6431-ambiguous-aliased-imports-not-reported branch June 14, 2023 10:18
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 this pull request may close these issues.

Ambiguous aliased imports not reported
4 participants