-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Raise proper error message if duplicate macros found #3165
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ed4af2
Raise proper error message if duplicate macros found
cgopalan 31989b8
Fix flake8 errors
cgopalan 5c50131
Fix failing test
cgopalan a8b2942
Fix duplicate macro path message
cgopalan 0e958f3
Add to changelog
cgopalan f4c7496
Add to contributor list
cgopalan 369b595
Merge branch 'develop' into dup-macro-message
jtcohen6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional check (
macro.original_file_path == other_path
) will also returnTrue
if a macro is defined multiple time, with the same name, in one file. Rather than try to disambiguate between these errors, I think it's fine to mention both possibilities in the error message:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtcohen6 thanks for the quick feedback. I was considering the case where the macro was in two file paths, for eg in
macros
directory and also in saymacros/some/other/dir
. In that casemacro.original_file_path == other_path
should not returnTrue
. Do we not want to address that case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I completely agree with your rationale.
In the case where
original_file_path != other_path
, we should definitely return thedup_macro_msg
error message that tells the user the path of each file in which the same-named macro is defined. (I believe we already do this.)In the case where
original_file_path == other_path
, that means either:a. The same file is parsed more than once, on account of a mistake in
macro-paths
b. The same-named macro is defined more than once in the same file (nothing to do with
macro-paths
)The preexisting error message handles only case 1. The current PR adds better error handling for case 2a; I believe the error message should mention the possibility of 2b as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I get what you are saying now. Thanks, makes sense! I have updated with changes and also added to changelog