source-academy/js-slang

Source 3 native lost imported functions when switching context from prepend to student's code

Closed this issue · 4 comments

source-academy/frontend#2419

In Source 3 Native, the import executed in the prepend for an assessment can NOT keep in student's code. You have to re-import the functions again in student's code or use another constant to hold the imported value in the prepend.

Screen.Recording.2023-10-16.at.12.09.45.PM.mov

Originally posted by @martin-henz in source-academy/frontend#2419 (comment)

I've actually already triaged and lodged an issue in #1495, and it has more details on the bug.

@sayomaki : the two issues may be related but describe different symptoms: One is talking about blocks the other one about the REPL.

@sayomaki : the two issues may be related but describe different symptoms: One is talking about blocks the other one about the REPL.

They are actually related, in the sense that the context is not preserved (since Source Native runs the code in native javascript), and as such the imported variables seems to be lost when executing (more) code. I will take a look again at this issue and see if it is possible to come up with a fix.