question-mark
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.

Variable defined in enclosing scope unusable in local scope

See original GitHub issue

Area of Cosmos - What area of Cosmos are we dealing with?

VS 2022, IL2CPU

Expected Behaviour - What do you think that should happen?

  1. I define 3 variables
  2. I enter a while loop
  3. I can use those variables in an if statement

Actual Behaviour - What unexpectedly happens?

  1. I define 3 variables
  2. I enter a while loop
  3. I try to use those variables in an if statement
  4. IL2CPU throws a hissy-fit.

Reproduction - How did you get this error to appear?

``bool selected,left,right; while(True){if(!selected){}}

Note: For that example, I skimmed down my code a lot, and haven’t tested that. VS2022 find did not find any other instances of a ‘selected’ variable in my entire codebase.

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

User kit, newest

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Neil-Ciciglycerincommented, Aug 2, 2023

man this sucked

0reactions
GoldenretriverYTcommented, Aug 2, 2023

@zarlo can you please ban him from creating issues, I think that’s possible somehow

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get a "local variable defined in enclosing scope ...
This is perfectly normal: Python considers that a variable is local if you assign to it anywhere in a function. So, total is...
Read more >
Python Variables Scope
If a variable is declared in an enclosing function, it is nonlocal to nested functions. It allows you to assign to variables in...
Read more >
Know the Scope of Local Variables
When a variable is declared in a method of a C# program, its scope is pre-defined and its visibility is defined for the...
Read more >
"Local variable (defined in enclosing scope) referenced ...
I got this message: "local variable 'my_data' defined in enclosing scope on line 1 referenced before assignment" flake8(F823) [Ln 8 Col 30]
Read more >
Python Scope
Local scope refers to variables that are defined within a function. These variables can only be accessed within the function and are destroyed...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found