Skip to content

Improve error message on assignment <non-js-like> to JS #373

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

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

krmbn0576
Copy link
Contributor

require "js"

JS.global[:document][:body][:innerHTML] = Object.new

# => eval:3:in `[]=': wrong argument type nil (expected jsvalue) (TypeError) eval:3:in `<main>'

Hmm this error message is difficult (internal error message?), so rewrited it as call method.

VALUE arg = _rb_js_try_convert(rb_mJS, argv[i]);
if (arg == Qnil) {
rb_raise(rb_eTypeError, "argument %d is not a JS::Object like object",
1 + i);
}

@krmbn0576
Copy link
Contributor Author

Sorry for the delay, but rake npm:ruby-head-wasm-wasi failed so I cannot continue fix 😭
Could you still build according to the procedures in CONTRIBUTING.md?

configure: error: cannot run /bin/bash config/config.sub
Try running with `rake --verbose` for more complete output.
bundler: failed to load command: rbwasm (/home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/bin/rbwasm)
/home/user/ruby.wasm/lib/ruby_wasm/build/executor.rb:77:in `system': Command failed with status (2): './configure' '--host' 'wasm32-wasi' 'CC=/home/user/ruby.wasm/build/toolchain/wasi-sdk/bin/clang' 'LD=/home/user/ruby.wasm/build/toolchain/wasi-sdk/bin/clang' 'AR=/home/user/ruby.wasm/build/toolchain/wasi-sdk/bin/llvm-ar' 'RANLIB=/home/user/ruby.wasm/build/toolchain/wasi-sdk/bin/llvm-ranlib' (RuntimeError)
        from /home/user/ruby.wasm/lib/ruby_wasm/build/product/libyaml.rb:61:in `build'
        from /home/user/ruby.wasm/lib/ruby_wasm/build/product/crossruby.rb:172:in `block in build'
        from /home/user/ruby.wasm/lib/ruby_wasm/build/product/crossruby.rb:170:in `each'
        from /home/user/ruby.wasm/lib/ruby_wasm/build/product/crossruby.rb:170:in `build'
        from /home/user/ruby.wasm/lib/ruby_wasm/packager/core.rb:78:in `block in build'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler.rb:403:in `block in with_unbundled_env'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler.rb:658:in `with_env'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler.rb:403:in `with_unbundled_env'
        from /home/user/ruby.wasm/lib/ruby_wasm/packager/core.rb:87:in `build'
        from /home/user/ruby.wasm/lib/ruby_wasm/packager/core.rb:10:in `build'
        from /home/user/ruby.wasm/lib/ruby_wasm/packager.rb:20:in `package'
        from /home/user/ruby.wasm/lib/ruby_wasm/cli.rb:196:in `do_build'
        from /home/user/ruby.wasm/lib/ruby_wasm/cli.rb:142:in `block in build'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/tmpdir.rb:99:in `mktmpdir'
        from /home/user/ruby.wasm/lib/ruby_wasm/cli.rb:141:in `build'
        from /home/user/ruby.wasm/lib/ruby_wasm/cli.rb:34:in `run'
        from /home/user/ruby.wasm/exe/rbwasm:7:in `<top (required)>'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/bin/rbwasm:25:in `load'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/bin/rbwasm:25:in `<top (required)>'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli/exec.rb:58:in `load'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli/exec.rb:23:in `run'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli.rb:451:in `exec'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli.rb:34:in `dispatch'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/cli.rb:28:in `start'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /home/user/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
        from /home/user/.rbenv/versions/3.3.0/bin/bundle:25:in `load'
        from /home/user/.rbenv/versions/3.3.0/bin/bundle:25:in `<main>'
rake aborted!
Command failed with status (1): [RUBY_WASM_ROOT=/home/user/ruby.wasm BUNDLE_GEMFILE=/home/user/ruby.wasm/packages/npm-packages/ruby-wasm-wasi/Gemfile bundle exec rbwasm build --ruby-version head --target wasm32-unknown-wasi --build-profile full --no-stdlib -o /home/user/ruby.wasm/packages/npm-packages/ruby-head-wasm-wasi/dist/ruby.wasm]
/home/user/ruby.wasm/rakelib/packaging.rake:64:in `block (4 levels) in <top (required)>'
/home/user/ruby.wasm/rakelib/packaging.rake:102:in `block (3 levels) in <top (required)>'
Tasks: TOP => npm:ruby-head-wasm-wasi:build => npm:ruby-head-wasm-wasi:ruby
(See full trace by running task with --trace)

@kateinoigakukun
Copy link
Member

@krmbn0576 #377 will fix it

@krmbn0576
Copy link
Contributor Author

Thanks for help, refined it!

wrong argument type Object (expected JS::Object like object)

@kateinoigakukun
Copy link
Member

Would you mind formatting C sources by rake format:c?

@krmbn0576
Copy link
Contributor Author

sorry, formatted!

@kateinoigakukun kateinoigakukun merged commit 5161477 into ruby:main Jan 30, 2024
@kateinoigakukun
Copy link
Member

Thanks!

@krmbn0576 krmbn0576 deleted the fix-aset-nonjs branch January 31, 2024 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants