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

Lexer doesn't handle all white spaces #154

Closed
evomassiny opened this issue Oct 14, 2019 · 0 comments
Closed

Lexer doesn't handle all white spaces #154

evomassiny opened this issue Oct 14, 2019 · 0 comments
Assignees

Comments

@evomassiny
Copy link
Contributor

Hello,

By toying with this crate I stumble across a slight bug in the lexer,
using the current boa version, any non-" " white space character triggers a lexing error,
this code:

fn main() {
    // mind the '\t' in the js expression
    let mut lexer = boa::syntax::lexer::Lexer::new("\tconsole.log('foo');");
    let lex_res = lexer.lex().expect("Lexing failed");
}

fails and produce this stacktrace:

Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/bug_demo`
thread 'main' panicked at '1:1: Unexpected '    '', /home/some_user/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/Boa-0.4.0/src/lib/syntax/lexer.rs:576:23
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
   7: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:384
   8: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:339
   9: boa::syntax::lexer::Lexer::lex
             at /home/some_user/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/Boa-0.4.0/src/lib/syntax/lexer.rs:576
  10: pac_proxy::main
             at src/main.rs:34
  11: std::rt::lang_start::{{closure}}
             at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  12: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:49
  13: std::panicking::try::do_call
             at src/libstd/panicking.rs:296
  14: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  15: std::panicking::try
             at src/libstd/panicking.rs:275
  16: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  17: std::rt::lang_start_internal
             at src/libstd/rt.rs:48
  18: std::rt::lang_start
             at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  19: main
  20: __libc_start_main
  21: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

According to the ECMASCRIPT specification, the \t should be simply ignored, as if it were a simple whitespace char.

Thank you for your time.

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

No branches or pull requests

2 participants