-
Notifications
You must be signed in to change notification settings - Fork 47
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
Class name collision #246
Class name collision #246
Conversation
refactor class lookup to be a map.
src/DiagnosticMessages.ts
Outdated
@@ -590,6 +590,11 @@ export let DiagnosticMessages = { | |||
message: `There are multiple components with the name '${componentName}'`, | |||
code: 1115, | |||
severity: DiagnosticSeverity.Error | |||
}), | |||
functionCannotHaveSameNameAsClass: (className: string) => ({ | |||
message: `Function cannot have the same name as class '${className}'`, |
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.
Maybe more consistent with LocalVar
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.
@elsassph which LocalVar message are you referring to?
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.
Oh, this one: localVarSameNameAsClass
. Yeah, good call. It's subtle, but they should be consistent.
src/Scope.ts
Outdated
if (lowerFuncName) { | ||
|
||
//find function declarations with the same name as a stdlib function | ||
if (globalCallableMap.has(func.getName(ParseMode.BrighterScript))) { |
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.
Use lowerFuncName
?
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.
oh yeah, good catch! I fixed it and added this unit test to ensure it doesn't regress.
Catch when local variables and scope functions have the same name as a class.
Fixes #245