Skip to content

Commit

Permalink
fix(transformer): RegExp transform only set span on final expression
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 6, 2024
1 parent 9d538fb commit 8ae571f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/oxc_transformer/src/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use oxc_regular_expression::ast::{
CharacterClass, CharacterClassContents, LookAroundAssertionKind, Pattern, Term,
};
use oxc_semantic::ReferenceFlags;
use oxc_span::Atom;
use oxc_span::{Atom, SPAN};
use oxc_traverse::{Traverse, TraverseCtx};

use crate::context::Ctx;
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<'a> Traverse<'a> for RegExp<'a> {
let callee = {
let symbol_id = ctx.scopes().find_binding(ctx.current_scope_id(), "RegExp");
let ident = ctx.create_reference_id(
regexp.span,
SPAN,
Atom::from("RegExp"),
symbol_id,
ReferenceFlags::read(),
Expand All @@ -174,14 +174,11 @@ impl<'a> Traverse<'a> for RegExp<'a> {

let mut arguments = ctx.ast.vec_with_capacity(2);
arguments.push(
ctx.ast.argument_expression(
ctx.ast.expression_string_literal(regexp.span, pattern_source),
),
ctx.ast.argument_expression(ctx.ast.expression_string_literal(SPAN, pattern_source)),
);

let flags = regexp.regex.flags.to_string();
let flags =
ctx.ast.argument_expression(ctx.ast.expression_string_literal(regexp.span, flags));
let flags = ctx.ast.argument_expression(ctx.ast.expression_string_literal(SPAN, flags));
arguments.push(flags);

*expr = ctx.ast.expression_new(
Expand Down

0 comments on commit 8ae571f

Please sign in to comment.