Skip to content
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
3 changes: 1 addition & 2 deletions crates/oxc_ecmascript/src/constant_evaluation/value_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> From<&Expression<'a>> for ValueType {
},
Expression::UnaryExpression(unary_expr) => match unary_expr.operator {
UnaryOperator::Void => Self::Undefined,
UnaryOperator::UnaryNegation => {
UnaryOperator::UnaryNegation | UnaryOperator::BitwiseNot => {
let argument_ty = Self::from(&unary_expr.argument);
match argument_ty {
Self::BigInt => Self::BigInt,
Expand All @@ -92,7 +92,6 @@ impl<'a> From<&Expression<'a>> for ValueType {
UnaryOperator::UnaryPlus => Self::Number,
UnaryOperator::LogicalNot | UnaryOperator::Delete => Self::Boolean,
UnaryOperator::Typeof => Self::String,
UnaryOperator::BitwiseNot => Self::Undetermined,
},
Expression::BinaryExpression(e) => Self::from(&**e),
Expression::SequenceExpression(e) => {
Expand Down
7 changes: 3 additions & 4 deletions crates/oxc_minifier/tests/ecmascript/value_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ fn unary_tests() {
test("-undefined", ValueType::Number); // NaN
test("-{ valueOf() { return 0n } }", ValueType::Undetermined);
test("-foo", ValueType::Undetermined); // can be number or bigint
test("~0", ValueType::Number);
test("~0n", ValueType::BigInt);
test("~foo", ValueType::Undetermined); // can be number or bigint

test("+0", ValueType::Number);
test("+true", ValueType::Number);
Expand All @@ -71,10 +74,6 @@ fn unary_tests() {

test("typeof 0", ValueType::String);
test("typeof foo", ValueType::String);

// test("~0", ValueType::Number);
// test("~0n", ValueType::BigInt);
test("~foo", ValueType::Undetermined); // can be number or bigint
}

#[test]
Expand Down
Loading