Boa: Boa cli `print` function panics

Created on 30 May 2020  路  7Comments  路  Source: boa-dev/boa

Describe the bug

The problem is that print uses builtins::console::log function, but it requires console state and it panics that no state was provided.

To Reproduce
Steps to reproduce the issue, or JavaScript code that causes this failure.

cargo run

print(10); // with any arbitrary message.

Expected behavior
This should print 10

But we get:

thread 'main' panicked at 'no state', boa/src/builtins/value/mod.rs:549:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional context
Potential fix would be to create a new function that diplays the values instead of calling console::log

bug cli

All 7 comments

I think we need an internal representation of a Logger, in order to first make console spec compliant, and then to be able to switch the Logger easily (so, it should implement a generic trait). Then, users could provide their own Logger, and we could also create easy tests for the output.

I don't really understand this issue. Is print(10) a javascript code or? If it is javascript code, why should it output 10?

I don't really understand this issue. Is print(10) a javascript code or? If it is javascript code, why should it output 10?

print is complaining that it can't print the value without the console state.
print is console.log, IMO I think we should remove it, we have console.log I don't think we need it

@HalidOdat How is print equal to console.log. In Chrome for example print invokes printing dialogue.

@HalidOdat How is print equal to console.log. In Chrome for example print invokes printing dialogue.

print in boa cli is set to console.log method here https://github.com/boa-dev/boa/blob/master/boa_cli/src/main.rs#L178

@HalidOdat Why would we do that if this is not the behavior neither in node, in chrome nor in FF?

@HalidOdat Why would we do that as this is not behavior neither in node, in chrome nor in FF?

No clue. This is why I suggested to remove it.

edit: I think it came from #74

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IovoslavIovchev picture IovoslavIovchev  路  4Comments

jasonwilliams picture jasonwilliams  路  6Comments

Razican picture Razican  路  4Comments

jasonwilliams picture jasonwilliams  路  4Comments

croraf picture croraf  路  5Comments