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

[bug]: VM emulator doesn't allow empty strings. #498

Open
2 tasks done
dorianignee opened this issue Nov 19, 2024 · 0 comments
Open
2 tasks done

[bug]: VM emulator doesn't allow empty strings. #498

dorianignee opened this issue Nov 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dorianignee
Copy link

Tool

VM Emulator

Interface

Website (https://nand2tetris.github.io/web-ide)

Contact Details

[email protected]

What happened?

The VM emulator throws ERR14 when working with an empty string.

Reproduction steps:

  1. paste the following code into a Main.jack file in the jack compiler:
class Main {
    function void main() {
        var String empty;
        let empty = "";
        return;
    }
}
  1. Click "Compile", then click "Run"
  2. When the VM emulator opened up, press the [>>] button to start the simulation

Workaround:
Since strings start empty and only contain characters, when they are appended using the String.appendChar(c) function, you can create an empty string with let empty = String.new(1);.

Additional Comments

No response

Do you want to try to fix this bug?

  • I want to try to add this feature!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@dorianignee dorianignee added the bug Something isn't working label Nov 19, 2024
dorianignee pushed a commit to dorianignee/nand2tetris-web-ide that referenced this issue Nov 19, 2024
The vm call String.new now only checks if `size` is negative, so that empty strings work as expected.
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
None yet
Development

No branches or pull requests

1 participant