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

No warning or error when defining a variable multiple times in the same scope #463

Open
jasal82 opened this issue Mar 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@jasal82
Copy link

jasal82 commented Mar 24, 2023

Observed behavior

fn foo() {
  let var = 1;
  var = 2; // OK
  let var = 3; // OK

fn bar(param) {
  param = 1; // OK
  let param = 2; // OK
}

Expected behavior

fn foo() {
  let var = 1;
  var = 2; // OK
  let var = 3; // should fail
}

fn bar(param) {
  param = 1; // OK
  let param = 2; // should at least warn
}
@udoprog udoprog added the enhancement New feature or request label Mar 25, 2023
@udoprog
Copy link
Collaborator

udoprog commented Mar 25, 2023

This is expected, since we've adopted the variable shadowing rules from Rust.

See playground.

Some of the unused warnings could be adopted though.

@jasal82
Copy link
Author

jasal82 commented Mar 25, 2023

That would help a bit I guess. As a C++ programmer I find the shadowing rules irritating enough in Rust, but what makes it worse in Rune is the combination with dynamic typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants