Skip to content

Generated range of value replaced in the inlined function #101

Open
@nicolo-ribaudo

Description

@nicolo-ribaudo

Consider this example:

function inlineMe(param) {
  beforeI;
  console.log(param + 3);
  afterI;
}

function fn(param) {
  beforeF;
  inlineMe(4 * otherFn(param));
  afterF;
}

fn(1);

That is compiled to

function fn(param) {
  beforeF;
  beforeI;
  console.log(4 * otherFn(param) + 3);
  afterI;
  afterF;
}

fn(1);

My initial naive implementation was to have three generated ranges:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to afterI, pointing to inlineMe's original scope

However, with those generated ranges, when placing a breakpoint right before the otherFn(param) call you would see the value for param as 4 rather than 1.

I think the correct generated ranges are either:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to afterI, pointing to inlineMe's original scope
  • one covering 4 * otherFn(param), pointing to fn's original scope

or:

  • one for the whole program
  • one going from beforeF to afterF, pointing to fn's original scope
  • one going from beforeI to right before 4 * otherFn(param), pointing to inlineMe's original scope
  • one going from + 3 to afterI, pointing to inlineMe's original scope

And I also think that the first one is slightly better since it better represents the stack trace when paused at that breakpoint.

Am I interpreting this correctly?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions