mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(ecmascript): fix may_have_side_effects for ${a() === b} (#9478)
`${a() === b}` has a sideeffect, but was not detected.
This commit is contained in:
2 files changed
+2
No files matched your search
@@ -89,6 +89,7 @@ impl MayHaveSideEffects for TemplateLiteral<'_> {
|
||||
// If the expression is a Symbol or ToPrimitive returns a Symbol, an error is thrown.
|
||||
// ToPrimitive returns the value as-is for non-Object values, so we can use it instead of ToString here.
|
||||
e.to_primitive(is_global_reference).is_symbol() != Some(false)
|
||||
|| e.may_have_side_effects(is_global_reference)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +354,7 @@ fn test_template_literal() {
|
||||
test("`${{ [s]() { console.log('sideeffect') } }}`", true); // assuming s is Symbol.toPrimitive
|
||||
test("`${a}`", true); // a maybe a symbol
|
||||
test("`${a()}`", true);
|
||||
test("`${a() === b}`", true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user