Skip to content

Fix undefined error line number #3420

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
wants to merge 1 commit into from
Closed

Fix undefined error line number #3420

wants to merge 1 commit into from

Conversation

pkch
Copy link
Contributor

@pkch pkch commented May 23, 2017

Fix #3415
Sorry, I meant to check for .node is None, but forgot.

Please check if the message is ok in case the line info unavailable.

@@ -3327,7 +3327,10 @@ def name_not_defined(self, name: str, ctx: Context) -> None:
def name_already_defined(self, name: str, ctx: Context,
original_ctx: Optional[SymbolTableNode] = None) -> None:
if original_ctx:
extra_msg = ' on line {}'.format(original_ctx.node.get_line())
if original_ctx.node and original_ctx.node.get_line() != -1:
Copy link
Member

Choose a reason for hiding this comment

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

IIUC the idea, then I would check for original_ctx.mod_id, and if it is not None then mention the module where original definition occurred. Otherwise, I would just set extra_msg = ''.

Copy link
Member

Choose a reason for hiding this comment

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

(This comment belongs to the else: branch below.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're trying to catch the cases where the definition is repeated twice in the same module, and indicate the line where the first one occurred. I don't think mod_id would ever be a different module if it gets to this line, right? It could be either None (when the definition was added from an import perhaps) or the same as the current module.

@pkch
Copy link
Contributor Author

pkch commented May 23, 2017

Closing this in favor of resubmitting the original PR.

@pkch pkch closed this May 23, 2017
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.

2 participants