js-slang icon indicating copy to clipboard operation
js-slang copied to clipboard

Stepper: steps appear as if capturing happens

Open martin-henz opened this issue 5 months ago • 0 comments

The stepper doesn't distinguish variables properly when they are already referring to functions:

https://share.sourceacademy.org/svqdz

function h(f, x) {
    function h(g, x) {
        return x <= 1 ? 1 : 3 * g(f, x - 1);
    }
    return x <= 1 ? 1 : 2 * f(h, x - 1);
}
h(h, 5);

Here, the two h in h(h(5 - 1)) refer to different values: Screenshot 2024-09-03 at 4 32 03 PM The fact that they are different becomes clear here: Screenshot 2024-09-03 at 4 32 17 PM Note that only one of the h are highlighted as being substituted.

The stepper should make clear that the two h are different by appropriately renaming one of them.

(This is called alpha-renaming, and already done properly for other cases.)

martin-henz avatar Sep 03 '24 08:09 martin-henz