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

Compiler allows a global variable name to be the same as a function name #516

Closed
yzhang90 opened this issue Nov 27, 2017 · 5 comments
Closed
Assignees
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@yzhang90
Copy link

What's your issue about?

The compiler should rejects the following program:

foo: decimal[3] 
@public def foo(): 
    self.foo = [1, 2.1, 3]

because the global variable and the function have the same name and it is very confusing to write such program.

How can it be fixed?

Checking name duplication in parser.py

Cute Animal Picture

image

@DavidKnott
Copy link
Contributor

@yzhang90 On it 👍

@DavidKnott DavidKnott self-assigned this Jan 15, 2018
@DavidKnott DavidKnott added pre beta bug Bug that shouldn't change language semantics when fixed. labels Jan 15, 2018
@DavidKnott
Copy link
Contributor

@fubuloubu I'm working on this. Do you think the following should be allowed?

def foo():
    foo: num

I'm leaning towards yes, as I'm thinking that uniforming naming can increase readability.

@fubuloubu
Copy link
Member

I'm not a big fan of that personally, but I think it would work because foo() is in the self "namespace" so that's fine

@jakerockland
Copy link
Contributor

jakerockland commented Feb 16, 2018

@yzhang90 @DavidKnott was poking around at bugs that could be addressed and ended up here, but it looks like this issue can be closed with #659 merged?

@jacqueswww
Copy link
Contributor

@jakerockland that is correct ;) sorry for the later reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

No branches or pull requests

5 participants