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

Differentiate Reference and mut #7910

Open
joe-conigliaro opened this issue Jan 6, 2021 · 0 comments
Open

Differentiate Reference and mut #7910

joe-conigliaro opened this issue Jan 6, 2021 · 0 comments
Labels
Reimplement Feature This issue is related to significant changes of existing feature.

Comments

@joe-conigliaro
Copy link
Member

Let's say a variable named my_var is declared using mut keyword: mut my_var = 1 the type of my_var will be int, and currently type.nr_muls will be incremented making a regular reference and a mut reference indistinguishable using the type.is_ptr() / type.nr_muls() methods. It is still possible to achieve but a little bit convoluted and confusing.

On the next use of my_var a new identifier will be created which will point to the variable declaration, it will also set ident.is_mut if the identifier was preceded by the mut for example in cases such as:

  • passed as a mutable function argument
  • used in a mut match: match mut my_var {
  • mutable loop var: for mut x in items

The implementation I'm suggesting will make it much cleaner and simpler to differentiate between regular reference and mutable variables.

@joe-conigliaro joe-conigliaro created this issue from a note in Joe C - TODO / WIP (To do) Jan 6, 2021
@joe-conigliaro joe-conigliaro added the Reimplement Feature This issue is related to significant changes of existing feature. label Jan 6, 2021
@joe-conigliaro joe-conigliaro moved this from To do to Review in progress in Joe C - TODO / WIP Jun 5, 2023
@joe-conigliaro joe-conigliaro moved this from Review in progress to New Compiler in Joe C - TODO / WIP Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reimplement Feature This issue is related to significant changes of existing feature.
Projects
No open projects
Joe C - TODO / WIP
Deferred (Built into New Compiler)
Development

No branches or pull requests

1 participant