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: scopes for with statements are not created (Object Environment Record) #8365

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

Comments

@sapphi-red
Copy link
Contributor

Currently semantic does not track scopes of with statements.
is_global_reference may return true even if that reference refers to a property of an object passed to a with statement.

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:

const foo = {
  Object: class {
    constructor() { console.log('Constructor') }
  }
}
with (foo) {
    console.log(new Object()) // should print "Constructor"
}

playground

This minification error may be fine as the minifier does not support with statements (for now?). But in this case, I think a warning should be output if the minifier found a with statement.

// Unable to minify non-strict code, which may contain syntaxes that the minifier do not support (e.g. `with`).

@sapphi-red sapphi-red added the C-bug Category - Bug label Jan 9, 2025
@Boshen Boshen self-assigned this Jan 9, 2025
@sapphi-red
Copy link
Contributor Author

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