Inside a function, I can't query a local variable declared outside the function

Reproduction Steps

  1. Put this in a script:
local myVar = 123
function b()
	print()
end
b()
  1. Set a breakpoint on line 3 (print)
  2. Run
  3. Add myVar to the Watch window and it will be shown as Symbol "myVar" not in scope:
    WnqlJ1kjeX
  4. Stop
  5. Change line 3 to print(myVar)
  6. Run
  7. Now myVar will be shown on My Watches:
    WnqlJ1kjeX
  8. Stop
  9. Change line 1 to from local myVar = 123 to myVar = 123
  10. Change back line 3 from print(myVar) to print()
  11. Run
  12. This way it will also be shown on My Watches:
    WnqlJ1kjeX

Expected Behavior
Since myVar belongs to the function scope, it should be shown in “My Watches”

Actual Behavior
myVar is only shown in “My Watches” in two cases:

  1. If I have any reference to this variable inside the function. Ex: print(myVar).
  2. If the variable is not declared as local. This is incongruous, as print(myVar) will print the contents of the variable, regardless of whether it is declared as local or not.

Issue Area: Studio
Issue Type: Display
Impact: Moderate
Frequency: Constantly

1 Like

Thanks for the report. We are looking into this.

3 Likes

After 6 months the problem continues, with the only difference that it is now showing nil (when MyVar is not mentioned inside the function (steps 1 to 4 in the op):

image

This is happening to me as well with the same exact reproduction steps. At first I thought it was due to watching inside of a module/on the client, but the same issue occurs regardless. Maybe I’m missing something, not entirely sure. Back to prints for now I 'spose

Closing the topic in favor to:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.