UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

Show variables for print #50

Closed rlisahuang closed 1 year ago

rlisahuang commented 1 year ago

Addressing #43, showing arguments of a print call if the arguments are variable names.

General Use Cases

For example,

a = 10
print(a)

shows a in a PB on the second line;

a = 10
b = 20
print(a,b)

shows a, b in a PB on the third line.

Potential Issues

In the following example

a = 10
b = 20
c = 30
print(a, b, b+c)

User might expect to see all of a b and c in PB for the fourth line, but only a and b will be displayed since b+c is not an identifier.

Also, in the following example (which is test/rtv/print/print_func_3.py)

a  = 10

def foo():
    global a
    a = a + 1
    return a

# expects to see a=10 in PB for the line below, but now it is showing 11
print(a, foo())

User might expect to see a=10in PB for the print call, but they will see 11 due to the side effect of foo(), which does not match Python semantics.

rlisahuang commented 1 year ago

Minor edits according to suggestions from @slerner to ensure that we only show print arg values in PB when the args are name expressions. Merging into leap.