ChakraCore icon indicating copy to clipboard operation
ChakraCore copied to clipboard

Use before declaration error has wrong line number.

Open akroshg opened this issue 10 years ago • 2 comments

function test3() {
  var k = 1;
  d = 2;
  let d;
}
test3();

Emits

ReferenceError: Use before declaration
   at test3 (e:\chgittest\bug8.js:2:3)
   at Global code (e:\chgittest\bug8.js:6:1)

The line number should be 3. EmitUseBeforeDeclarationdoes not have enclosing Start/End Statement.

akroshg avatar Mar 10 '16 01:03 akroshg

This is a symptom of the use before declaration check occurring at the beginning of Emit() in ByteCodeEmitter.cpp, before individual nodes are processed and their corresponding start/end statement calls made.

I would like to move the use before declaration check into those individual cases for this reason and a few other reasons. This issue should be fixed when I do that.

ianwjhalliday avatar Mar 10 '16 02:03 ianwjhalliday

Fixed by #936

ianwjhalliday avatar May 12 '16 00:05 ianwjhalliday