Repository navigation
Closed
Labels
A-BugSomething isn't workingC-ParserIssues surrounding the parserHelp WantedExtra attention is needed
Milestone
Description
When putting the following in test.js:
var`a = 1;
running the command cargo run -- test.js will give the following panic:
Finished dev [unoptimized + debuginfo] target(s) in 0.14s
Running `target\debug\boa.exe test.js`
thread 'main' panicked at '1:4: Unexpected '`'', src/lib\syntax\lexer.rs:620:22
stack backtrace:
0: 0x7ff636d9a689 - backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace\mod.rs:66
1: 0x7ff636d9a689 - std::sys_common::backtrace::_print_fmt
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:77
2: 0x7ff636d9a689 - std::sys_common::backtrace::_print::{{impl}}::fmt
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:59
3: 0x7ff636db007b - core::fmt::write
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libcore\fmt\mod.rs:1052
4: 0x7ff636d98244 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\io\mod.rs:1428
5: 0x7ff636d9cfbc - std::sys_common::backtrace::_print
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:62
6: 0x7ff636d9cfbc - std::sys_common::backtrace::print
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\sys_common\backtrace.rs:49
7: 0x7ff636d9cfbc - std::panicking::default_hook::{{closure}}
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:204
8: 0x7ff636d9cc0c - std::panicking::default_hook
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:224
9: 0x7ff636d9d70f - std::panicking::rust_panic_with_hook
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:472
10: 0x7ff636d9d295 - std::panicking::begin_panic_handler
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:380
11: 0x7ff636d9d20c - std::panicking::begin_panic_fmt
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:334
12: 0x7ff6369f4511 - boa::syntax::lexer::Lexer::lex
at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\syntax\lexer.rs:620
13: 0x7ff6369f3121 - boa::parser_expr
at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:24
14: 0x7ff6369f32b8 - boa::forward
at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:33
15: 0x7ff6369f36b8 - boa::exec
at C:\Users\nathaniel\Documents\GitHub\boa\src\lib\lib.rs:56
16: 0x7ff6369f1d7d - boa::main
at C:\Users\nathaniel\Documents\GitHub\boa\src\bin\bin.rs:38
17: 0x7ff6369f2335 - std::rt::lang_start::{{closure}}<core::result::Result<(), std::io::error::Error>>
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\src\libstd\rt.rs:67
18: 0x7ff636d9d137 - std::rt::lang_start_internal::{{closure}}
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\rt.rs:52
19: 0x7ff636d9d137 - std::panicking::try::do_call<closure-0,i32>
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:305
20: 0x7ff636da06a2 - panic_unwind::__rust_maybe_catch_panic
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libpanic_unwind\lib.rs:86
21: 0x7ff636d9d932 - std::panicking::try
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panicking.rs:281
22: 0x7ff636d9d932 - std::panic::catch_unwind
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\panic.rs:394
23: 0x7ff636d9d932 - std::rt::lang_start_internal
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\/src\libstd\rt.rs:51
24: 0x7ff6369f230b - std::rt::lang_start<core::result::Result<(), std::io::error::Error>>
at /rustc/212b2c7da87f3086af535b33a9ca6b5242f2d5a7\src\libstd\rt.rs:67
25: 0x7ff6369f2100 - main
26: 0x7ff636db6878 - invoke_main
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
27: 0x7ff636db6878 - __scrt_common_main_seh
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
28: 0x7fff816a7bd4 - BaseThreadInitThunk
29: 0x7fff82acced1 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\boa.exe test.js` (exit code: 101)
This should probably be an error, not a panic.
Metadata
Metadata
Assignees
Labels
A-BugSomething isn't workingC-ParserIssues surrounding the parserHelp WantedExtra attention is needed
Activity
jasonwilliams commentedon Feb 2, 2020
Thanks @adumbidiot
You’ve touched upon on a deeper problem Boa has right now, which is lack of error handling on all layers. The best way for us to get up and running was to just let things panic, but we should put some work in to have proper stderr messages, maybe starting with the lexer/parser.
adumbidiot commentedon Feb 2, 2020
Would it be helpful to try to replace some of the panics in the lexer with the
LexerErrors?croraf commentedon Feb 2, 2020
@jasonwilliams I guess a LexerError is when the user inputs something that is not allowed as per JS specification. That will show him that his code is invalid. What happens here is that ` is not implemented in Boa, so I think "panic" is ok, as it is actually bugs out in Boa before realizing it is invalid as per JS syntax.
If template literals were implemented it should show LexerError, something like:

adumbidiot commentedon Feb 2, 2020
I still kinda feel like the engine should still return an error. Just as older engines reject newer syntax with lexing and parsing errors and such, I feel like Boa should reject syntax it doesn't support with errors.
jasonwilliams commentedon Feb 2, 2020
It should be possible to return an Err(LexerError) here:
https://github.com/jasonwilliams/boa/blob/master/src/lib/syntax/lexer.rs#L620-L622
Then perform a match here:
https://github.com/jasonwilliams/boa/blob/master/src/lib/lib.rs#L24
printing a stderr with the message from the Err() if there is one.
This would be a good start.
jasonwilliams commentedon Feb 4, 2020
This has now been fixed, thanks @adumbidiot
adumbidiot commentedon Feb 4, 2020
I feel like a lot more work has to be done here; My pull only fixed some of the lexer panics and none of the parser panics.
jasonwilliams commentedon Mar 31, 2020
@adumbidiot have you tried this against the new parser?
Parser fixes #225 #240 #273 (#281)
jasonwilliams commentedon Apr 13, 2020
I'm going to close this issue as the main problem in question has been fixed, and some other parser issues have been resolved.
If there are new issues we should make a ticket for them
Razican commentedon Sep 2, 2020
I want to re-open this, since it seems this is now also panicking. We should never panic, and checking what this gives in Firefox, for example, I can see the following:
So, let's re-open it and track it, since we get this panic:
It seems that in the test262 branch this is fixed: