Closed Bug 940086 Opened 11 years ago Closed 5 months ago

[reflect.jsm] FunctionDeclaration nodes' locations start on the identifier, not the "function" keyword

Categories

(Core :: JavaScript Engine, defect)

25 Branch
x86
macOS
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: fitzgen, Unassigned)

Details

If you parse

  function foo() {
    doStuff();
  }

with location information, the FunctionDeclaration node reports its start column as 9, when it should be 0.

-------------------

In devtools, we want to use Reflect.jsm to parse some text, and then find the sub-slice of the text that corresponds to specific function declarations so we can eval that sub-slice of text to provide simple live editing or something similar to Emacs' eval-defun[0]. We can't do this if we can't rely on the locations reported by Reflect.jsm to be correct.

[0] http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html
I think those coordinates are also used for lazy compilation; but it seems like there's no reason lazy compilation needs to change the function node's coordinates, when it could just as well fetch what it needs from a more appropriate parse node.
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.