Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored and camchenry committed Oct 27, 2024
1 parent 520fd5e commit 7ef60cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ num-traits = { workspace = true }

[dev-dependencies]
# Parser and allocator are only used in tests to make testing easier
oxc_parser = { workspace = true }
oxc_allocator = { workspace = true }
oxc_parser = { workspace = true }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ecmascript/src/prop_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod test {
assert!(!ret.program.is_empty());
assert!(ret.errors.is_empty());

let mut visitor = TestVisitor::default();
let mut visitor = TestVisitor;
visitor.visit_program(&ret.program);
}
}
20 changes: 14 additions & 6 deletions crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,13 +984,21 @@ pub fn check_object_expression(obj_expr: &ObjectExpression, ctx: &SemanticBuilde
// It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate entries for "__proto__"
// and at least two of those entries were obtained from productions of the form PropertyDefinition : PropertyName : AssignmentExpression
let mut prev_proto: Option<Span> = None;
let prop_names = obj_expr.properties.iter().filter_map(PropName::prop_name);
for prop_name in prop_names {
if prop_name.0 == "__proto__" {
if let Some(prev_span) = prev_proto {
ctx.error(redeclaration("__proto__", prev_span, prop_name.1));
for prop in &obj_expr.properties {
if let ObjectPropertyKind::ObjectProperty(obj_prop) = prop {
// Skip if not a property definition production:
// PropertyDefinition : PropertyName : AssignmentExpression
if obj_prop.kind != PropertyKind::Init || obj_prop.method {
continue;
}
if let Some((prop_name, span)) = prop.prop_name() {
if prop_name == "__proto__" {
if let Some(prev_span) = prev_proto {
ctx.error(redeclaration("__proto__", prev_span, span));
}
prev_proto = Some(span);
}
}
prev_proto = Some(prop_name.1);
}
}
}
Expand Down

0 comments on commit 7ef60cf

Please sign in to comment.