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

const local variable is not constant at all #10575

Closed
yuyichao opened this issue Mar 19, 2015 · 1 comment
Closed

const local variable is not constant at all #10575

yuyichao opened this issue Mar 19, 2015 · 1 comment

Comments

@yuyichao
Copy link
Contributor

julia> function f()
       const a = 1;
       a = 2;
       return a;
       end
f (generic function with 1 method)

julia> f()
2

Although it is not that important for the compiler/optimizer to declare a local constant variable as it can probably figure out itself, it is still useful as a hint/constraint for the user to avoid stupid error or breakage sometimes.

IMHO, as long as local const variable is a valid syntax, it should at least give a warning if the value/binding changes (just as the global one). It might even make sense to be more restrictive and make that an error instead of a warning.

@simonster
Copy link
Member

Duplicate of #5148

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

No branches or pull requests

2 participants