Skip to content

semantics: references created by direct eval in non-strict mode is not respected #8372

@sapphi-red

Description

@sapphi-red

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).

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()

playground

I'd say just never use direct eval 😅 But leaving a note for reference. (This is not something I met with real world code)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions