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

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

Open
sapphi-red opened this issue Jan 9, 2025 · 1 comment
Labels
C-bug Category - Bug

Comments

@sapphi-red
Copy link
Contributor

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)

@sapphi-red sapphi-red added the C-bug Category - Bug label Jan 9, 2025
@Boshen
Copy link
Member

Boshen commented Jan 9, 2025

All logic related to eval has not been implemented yet. We need to either implement them or warn about it. Note: esbuild bails minification and mangling for all parent scopes containing eval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

No branches or pull requests

2 participants