source-academy/js-slang

CSE Machine: "Redeclaring name" error

Closed this issue · 1 comments

This program runs correctly in the default runtime, but gives an error when run in CSE machine:

function f() {
    function g(t) {
        return 0;
    }
    return g;
}
const h = f();
h(100);

(https://share.sourceacademy.nus.edu.sg/i8q0o)

The error: Line 7: Redeclaring name h.

If function f has at least one parameter, the CSE machine will work correctly.