Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assigned value is discarded when exiting an inner scope

See original GitHub issue
ask {
    let a = 2

    let c = 'Hello'
    if(a < 5) {
        c = '!'
    return c

returns Hello instead of !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

YonatanKracommented, Jun 18, 2020

@mhagmajer I dug a little into the runner. It seems like that c = '!' redeclares c with a let. When running @czerwinskilukasz1 's test, I get this object:

    "name": "let",
    "params": [

In the statements inside fun.ts compute method. Since it is a scoped let statement, it is, well… scoped 😃

It seems like the scope is lost when fragments.ts calls fun.compute on a block. losingScope

mhagmajercommented, Jun 19, 2020

@YonatanKra I think we should throw a runtime error on when someone attempt to assign value to a undeclared variable. It’s the same like trying to read an undeclared variable - we throw in that case already

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Are variables inside a loop (while or for) disposed after ...
Outside the scope that particular variable even doesn't exits, forget about accessing its value. for(;;) { int var; // Scope of this variable...
Read more >
Discards - unassigned discardable variables - Microsoft Learn
Discards are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; they don' ...
Read more >
Variable scope, closure - The Modern JavaScript Tutorial
When the code wants to access a variable – the inner Lexical Environment is searched first, then the outer one, then the more...
Read more >
Variables and scope - Object-Oriented Programming in Python
To define a new variable in Python, we simply assign a value to a label. For example, this is how we create a...
Read more >
2.5 — Introduction to local scope - Learn C++
A local variable's scope begins at the point of variable definition, and stops at the end of the set of curly braces in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found