Skip to content

As part of incremental type checking, when filtering out potentially unwanted parser errors, don't ignore the multiple definitions type error #1086

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

Merged

Conversation

mediremi
Copy link
Contributor

When using incremental type checking, if the compiler reports the multiple definitions type error, the user will see a warning notification:

image

The reason why this happens is as follows:

  • incrementalCompilation.compileContents filters out diagnostic messages parsed from the compiler’s stderr that either:
    i) start with Uninterpreted extension 'rescript. or,
    ii) include the source file name

.filter((d) => {
if (
!d.message.startsWith("Uninterpreted extension 'rescript.") &&
!d.message.includes(
`/${INCREMENTAL_FOLDER_NAME}/${entry.file.sourceFileName}`
)
) {
hasIgnoredErrorMessages = true;
return true;
}
return false;

  • If all the diagnostic messages extracted from the compiler’s output are filtered out due to matching at least one of the conditions above, then res.length == 0 and hasIgnoredErrorMessages = false
  • This then leads to a notification being shown telling the user that something may have gone wrong with incremental type checking
  • Unfortunately, the logic for this doesn’t handle one edge case: the multiple definitions type error (Multiple definition of the <kind> name <name>) prints out the LOC of the repeated definition
  • By printing out the full LOC, including source file name, this triggers condition number 2 of the filter: !d.message.includes(`/${INCREMENTAL_FOLDER_NAME}/${entry.file.sourceFileName}`)
  • Which then triggers the error notification

This PR fixes this issue by adding an exception to the filter for error messages that include the string "Multiple definition of the".

…unwanted parser errors, don't ignore the multiple definitions type error
@mediremi mediremi force-pushed the fix-incremental-comp-multi-defn-error branch from 19512ad to 7406e82 Compare April 29, 2025 12:39
Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

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

Great find, thank you very much!

@zth zth merged commit aca332d into rescript-lang:master Apr 29, 2025
6 checks passed
@nojaf
Copy link
Contributor

nojaf commented Apr 29, 2025

Great work on these last PRs @mediremi!

@mediremi
Copy link
Contributor Author

Thank you!

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.

3 participants