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

Native: Importing new names in the REPL do not work properly #1495

Open
sayomaki opened this issue Oct 17, 2023 · 2 comments
Open

Native: Importing new names in the REPL do not work properly #1495

sayomaki opened this issue Oct 17, 2023 · 2 comments
Labels
Bug Something isn't working

Comments

@sayomaki
Copy link
Contributor

sayomaki commented Oct 17, 2023

EDIT: Imports in prelude and in main editor have been resolved as of #1625.

The issue left is importing new names in the REPL, refer to the same example below for a reproduction of the issue.

Here is the original issue:


When importing module functions and not using it directly (in the current program), this will lead to them being undeclared, i.e. using it in another program sharing the same context will lead to an error with name being undeclared.

However, this is not an issue/the case with the default source versions.

This causes issues when trying to execute module functions under REPL in different cells, or in the case of assessments, any module functions imported in the prepend chunk will not be declared and imported properly in the student's running program. (see examples below)

Affected Chapters & Variants

  • Source 1 to 4, Native variant

Affected Modules

  • All modules

Reproduction

1. Playground

Run these 2 chunks of code in separate cells (in the REPL), and you will see that the only the first cell works correctly.

import { noise_sound } from "sound";
noise_sound(2);

noise_sound(2); // doesn't work
Screenshot 2023-10-17 at 6 05 21 PM

2. Assessment

Create any assessment with prepend importing a module, then set the interpreter variant to native.
You will see that the imported module functions do not work in the assessment. (see source-academy/frontend#2419 (comment))

Workarounds

  • For now, when using Source 1-4 Native, you will have to ensure the imports share the same program block as the actual code
  • As for assessments, it will need to be manually imported by the students or given as part of the placeholder template.
@sayomaki sayomaki added the Bug Something isn't working label Oct 17, 2023
@sayomaki sayomaki changed the title Native: Imported modules do not carry over in different evaluation steps Native: Imported modules do not carry over between different code evaluation blocks Oct 17, 2023
@martin-henz
Copy link
Member

This issue persists as of today.

@martin-henz martin-henz added the critical Fixing this is mission-critical label Mar 30, 2024
@sayomaki sayomaki removed the critical Fixing this is mission-critical label Apr 8, 2024
@sayomaki sayomaki changed the title Native: Imported modules do not carry over between different code evaluation blocks Native: Importing new names in the REPL do not work properly Apr 8, 2024
@sayomaki
Copy link
Contributor Author

sayomaki commented Apr 8, 2024

The issue where imports do not carry over in assessment prelude and from the main code editor (on the left in playground) has been resolved in #1625, however importing new names in REPL issue still persists.

The issue title and post has been updated accordingly to reflect the updated issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

2 participants