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

Calling a function with parameters that was imported via "require/module.exports" causes an error #3502

Closed
mweigle opened this issue Dec 5, 2023 · 1 comment
Labels
bug Something isn't working execution Issues or PRs related to code execution vm Issues and PRs related to the Boa Virtual Machine.

Comments

@mweigle
Copy link

mweigle commented Dec 5, 2023

Describe the bug
I tried implementing a module loader that behaves like require/module.exports and followed the example in https://github.com/boa-dev/boa/blob/main/boa_examples/src/bin/modulehandler.rs. Importing a calling functions without arguments works fine but when I try to call something with arguments I always get the error

thread 'nodes::test_javascript::nodes::load_module' panicked at C:\Users\maxim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\boa_engine-0.17.3\src\vm\opcode\define\mod.rs:84:33:
index out of bounds: the len is 1 but the index is 1

To Reproduce
Run the example dev/boa/blob/main/boa_examples/src/bin/modulehandler.rs or use it to run JS-Code that looks something like this:

    let myMod = require("./myMod.js");
    myMod.fnWithoutArgs(); // works
    myMod.fnWithArg(5); // fails
    myMod.fnWithArgs(3, 3); // fails

Expected behavior
I expect the functions to be callable with the appropriate number of arguments.

Build environment (please complete the following information):

  • OS: Windows
  • Version: 10
  • Target triple: stable-x86_64-pc-windows-msvc
  • Rustc version:rustc 1.74.0 (79e9716c9 2023-11-13)
@mweigle mweigle added the bug Something isn't working label Dec 5, 2023
@jedel1043 jedel1043 added execution Issues or PRs related to code execution vm Issues and PRs related to the Boa Virtual Machine. labels Dec 6, 2023
@jedel1043
Copy link
Member

This seems to work fine on main. Will close this, but feel free to reopen the issue if the code is still panicking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working execution Issues or PRs related to code execution vm Issues and PRs related to the Boa Virtual Machine.
Projects
Status: Done
Development

No branches or pull requests

2 participants