Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoping issues in REPL when using explicit control variants #1550

Open
s-kybound opened this issue Feb 19, 2024 · 3 comments
Open

Scoping issues in REPL when using explicit control variants #1550

s-kybound opened this issue Feb 19, 2024 · 3 comments
Labels
Bug Something isn't working critical Fixing this is mission-critical

Comments

@s-kybound
Copy link
Member

s-kybound commented Feb 19, 2024

The following program, entered statement by statement in separate cells into the REPL when using js-slang --variant=explicit-control, returns error "Name a not declared."

const a = 1;

const b = 1;

const c = a;

Any reference to a after const b = 1 returns an error.

The same behaviour can be seen with replacing const b = 1; with an IIFE such as (x => x)(a); - after the IIFE, a is not found.

I suspect this has to do with the way the current environment is handled (as an array of environments in context.runtime.environments).

@s-kybound s-kybound added Bug Something isn't working critical Fixing this is mission-critical labels Feb 19, 2024
@martin-henz martin-henz changed the title CSE Machine: Scoping issues in REPL when using explicit control variants Scoping issues in REPL when using explicit control variants Mar 5, 2024
@martin-henz
Copy link
Member

Note: this problem does not seem to occur in Source Academy:
Screenshot 2024-03-30 at 6 16 41 PM

@s-kybound
Copy link
Member Author

resolved with #1584

@s-kybound s-kybound reopened this Apr 14, 2024
@s-kybound
Copy link
Member Author

The problem persists, as functions defined using preludes are "forgotten" with each new program execution.

The following program, entered statement by statement in separate cells into the REPL when using js-slang --variant=explicit-control, returns error "Name map not declared."

map(x => x, list(1, 2, 3));

map;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working critical Fixing this is mission-critical
Projects
None yet
Development

No branches or pull requests

2 participants