askql icon indicating copy to clipboard operation
askql copied to clipboard

Multiple variable declarations in the same scope do not result in an error.

Open czerwinskilukasz1 opened this issue 5 years ago • 6 comments

🦄 .editor
// Entering editor mode (^D to finish, ^C to cancel)
let a = 3
let a = 4
a

Expected: Error - variable 'a' is already defined in this scope

Actual: Success

int ask(let('a',3),let('a',4),get('a'))
4
🦄 

czerwinskilukasz1 avatar Jun 27 '20 08:06 czerwinskilukasz1

Same for let and const in the same scope:

🦄 .editor 
// Entering editor mode (^D to finish, ^C to cancel)
let a = 3
const a = 4
a

Expected: Error - variable 'a' is already defined in this scope

Actual:

int ask(let('a',3),const('a',4),get('a'))
4
🦄 

and consts:

🦄 .editor
// Entering editor mode (^D to finish, ^C to cancel)
const a = 3
const a = 4
a

Expected: Error - variable 'a' is already defined in this scope

Actual:

int ask(const('a',3),const('a',4),get('a'))
4

czerwinskilukasz1 avatar Jun 27 '20 13:06 czerwinskilukasz1

@czerwinskilukasz1 I'm not sure if there is issue for it, but we don't do any differentiation between const and let currently

mhagmajer avatar Jun 27 '20 13:06 mhagmajer

@czerwinskilukasz1 I'm not sure if there is issue for it, but we don't do any differentiation between const and let currently

I added it earlier today: "Assigning to a const does not result in an error" https://github.com/xFAANG/askql/issues/254

czerwinskilukasz1 avatar Jun 27 '20 14:06 czerwinskilukasz1

@czerwinskilukasz1 thanks

mhagmajer avatar Jun 27 '20 14:06 mhagmajer

Hey @mhagmajer and @czerwinskilukasz1 , I'm new here and I would love to contribute. Can you guide me what I need to do to resolve this?

avats-dev avatar Aug 05 '20 18:08 avats-dev

Hello Aditya, welcome to AskQL project! This issue is related to AskVM (Ask Virtual Machine), which is interpreting code in AskCode and keeping track of resources (functions) and variables defined. First, it would be good if you get familiar with the part of code you are going to work on. In this case it is how defining variables work in AskVM. The code for AskVM lives in src/askvm, while for the code which handles defining variables start looking at src/askvm/resources/core/let.ts. Try to understand how it works now and why executing let a = <value> twice does not cause an error. @avats-dev

Let me know if you have more questions.

czerwinskilukasz1 avatar Aug 10 '20 15:08 czerwinskilukasz1