oxc icon indicating copy to clipboard operation
oxc copied to clipboard

playground: `Runtime Error: unreachble`

Open Dunqing opened this issue 9 months ago • 1 comments

OXC Playground

if (true) function g() {}
let g = 0;

Dunqing avatar Mar 24 '25 11:03 Dunqing

Caused by https://github.com/oxc-project/oxc/blob/0a33e2792f23effe51bf13e955de14a8c9a0b9c6/crates/oxc_semantic/src/binder.rs#L160

Stack trace:

thread '<unnamed>' panicked at /Users/boshen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/oxc_index-3.0.0/src/indexing.rs:38:10:
index out of bounds: the len is 2 but the index is 4294967294
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <I as oxc_index::indexing::IdxSliceIndex<I,T>>::index
   4: oxc_index::indexing::<impl core::ops::index::Index<R> for oxc_index::idxslice::IndexSlice<I,[T]>>::index
   5: oxc_semantic::scoping::Scoping::scope_flags
   6: oxc_linter::rules::eslint::no_unused_vars::symbol::Symbol::is_in_ts_namespace
   7: oxc_linter::rules::eslint::no_unused_vars::symbol::Symbol::is_exported
   8: oxc_linter::rules::eslint::no_unused_vars::NoUnusedVars::run_on_symbol_internal
   9: <oxc_linter::rules::eslint::no_unused_vars::NoUnusedVars as oxc_linter::rule::Rule>::run_on_symbol
  10: oxc_linter::rules::RuleEnum::run_on_symbol
  11: oxc_linter::Linter::run

Replicate by forcing

        let source_type = source_type.with_script(true);

in crates/oxc_linter/src/service/runtime.rs

Boshen avatar Mar 30 '25 06:03 Boshen