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

refactor(semantic): shorten code #4358

Merged
merged 1 commit into from
Jul 19, 2024
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
4 changes: 2 additions & 2 deletions crates/oxc_semantic/src/checker/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ fn unexpected_type_annotation(span0: Span) -> OxcDiagnostic {

pub fn check_array_pattern<'a>(pattern: &ArrayPattern<'a>, ctx: &SemanticBuilder<'a>) {
for element in &pattern.elements {
let _ = element.as_ref().map(|element| {
if let Some(element) = element.as_ref() {
if let Some(type_annotation) = &element.type_annotation {
ctx.error(unexpected_type_annotation(type_annotation.span));
}
});
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_semantic/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ impl ScopeTree {
flags: ScopeFlags,
) -> ScopeId {
let scope_id = self.parent_ids.push(parent_id);
_ = self.child_ids.push(vec![]);
_ = self.flags.push(flags);
_ = self.bindings.push(Bindings::default());
_ = self.node_ids.push(node_id);
self.child_ids.push(vec![]);
self.flags.push(flags);
self.bindings.push(Bindings::default());
self.node_ids.push(node_id);

// Set this scope as child of parent scope.
if let Some(parent_id) = parent_id {
Expand Down
10 changes: 5 additions & 5 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ impl SymbolTable {
flag: SymbolFlags,
scope_id: ScopeId,
) -> SymbolId {
_ = self.spans.push(span);
_ = self.names.push(name);
_ = self.flags.push(flag);
_ = self.scope_ids.push(scope_id);
_ = self.resolved_references.push(vec![]);
self.spans.push(span);
self.names.push(name);
self.flags.push(flag);
self.scope_ids.push(scope_id);
self.resolved_references.push(vec![]);
self.redeclare_variables.push(vec![])
}

Expand Down