Skip to content

Commit f4f4a67

Browse files
committed
fix #375 - location are null
1 parent d0f27b0 commit f4f4a67

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/parser/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ module.exports = {
112112
read_byref: function(cb) {
113113
let byref = this.node("byref");
114114
this.next();
115-
byref = byref();
115+
byref = byref(null);
116116
const result = cb();
117-
this.ast.swapLocations(result, byref, result, this);
118-
result.byref = true;
117+
if (result) {
118+
this.ast.swapLocations(result, byref, result, this);
119+
result.byref = true;
120+
}
119121
return result;
120122
},
121123

test/debug.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@
1717
const util = require('util');
1818
const parser = require("../src/index");
1919
const ast = parser.parseEval(`
20-
$foo = new Foo(
21-
'constructor',
22-
'bar',
23-
);
20+
$bar = &$foo;
2421
`, {
2522
parser: {
2623
debug: true,
2724
php73: true,
2825
extractDoc: true
2926
},
30-
/*ast: {
27+
ast: {
3128
withPositions: true,
3229
withSource: true
33-
}*/
30+
}
3431
}
3532
);
3633
console.log(

0 commit comments

Comments
 (0)