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

Unwrap sequence await callee in analyzer #3623

Merged
merged 4 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/turbopack-ecmascript/src/analyzer/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ impl EvalContext {
SyntaxContext::empty(),
)),

Expr::Await(AwaitExpr { arg, .. }) => self.eval(arg),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it's not super correct. e. g. (await { then: () => ({ v: 42 }), v: 43 }).v evaluates to 43 instead of 42, but I'm fine with that for now...


Expr::New(..) => JsValue::Unknown(None, "unknown new expression"),

Expr::Seq(e) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-ecmascript/src/analyzer/well_known.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ pub async fn well_known_object_member(
WellKnownObjectKind::PathModule | WellKnownObjectKind::PathModuleDefault => {
path_module_member(kind, prop)
}
WellKnownObjectKind::FsModule | WellKnownObjectKind::FsModuleDefault => {
fs_module_member(kind, prop)
}
WellKnownObjectKind::FsModule
| WellKnownObjectKind::FsModuleDefault
| WellKnownObjectKind::FsModulePromises => fs_module_member(kind, prop),
WellKnownObjectKind::UrlModule | WellKnownObjectKind::UrlModuleDefault => {
url_module_member(kind, prop)
}
Expand Down
3 changes: 3 additions & 0 deletions crates/turbopack-ecmascript/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub fn unparen(expr: &Expr) -> &Expr {
if let Some(expr) = expr.as_paren() {
return unparen(&expr.expr);
}
if let Expr::Seq(seq) = expr {
return unparen(seq.exprs.last().unwrap());
}
expr
}

Expand Down
Loading