Merge pull request #3586 from loganfsmyth/fix-retainLines-generator-issue

Avoid duplicated identifier sharing location - fixes T7436
This commit is contained in:
Logan Smyth 2016-07-18 20:56:57 -07:00 committed by GitHub
commit ab47b439cc
4 changed files with 22 additions and 1 deletions

View File

@ -26,7 +26,9 @@ exports.hoist = function(funPath) {
let exprs = [];
vdec.declarations.forEach(function(dec) {
vars[dec.id.name] = dec.id;
// Note: We duplicate 'dec.id' here to ensure that the variable declaration IDs don't
// have the same 'loc' value, since that can make sourcemaps and retainLines behave poorly.
vars[dec.id.name] = t.identifier(dec.id.name);
if (dec.init) {
exprs.push(t.assignmentExpression(

View File

@ -0,0 +1,7 @@
var func = function * (){
yield obj
.method()
.method2();
const actual = true;
};

View File

@ -0,0 +1,6 @@
var func = regeneratorRuntime.mark(function _callee() {var actual;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) switch (_context.prev = _context.next) {case 0:_context.next = 2;return (
obj.
method().
method2());case 2:
actual = true;case 3:case "end":return _context.stop();}}, _callee, this);});

View File

@ -0,0 +1,6 @@
{
"plugins": [
"transform-regenerator"
],
"retainLines": true
}