-
-
Notifications
You must be signed in to change notification settings - Fork 722
Open
Labels
Milestone
Description
Currently semantic does not track the existence of direct eval.
is_global_reference may return true even if that reference refers to a variable declared by direct eval (the declaration is only leaked outside in non-strict mode).
oxc/crates/oxc_semantic/src/symbol.rs
Lines 342 to 346 in e4d66e4
| fn is_global_reference(&self, symbols: &SymbolTable) -> bool { | |
| self.reference_id | |
| .get() | |
| .is_some_and(|reference_id| reference_id.is_global_reference(symbols)) | |
| } |
This leads to minification errors for codes like:
function foo() {
eval('var Object = class { constructor() { console.log("Constructor") } }')
console.log(new Object())
}
foo()I'd say just never use direct eval 😅 But leaving a note for reference. (This is not something I met with real world code)