Skip to content

Commit

Permalink
fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
dpomier committed Dec 21, 2023
1 parent d2d0459 commit 26e9e08
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
31 changes: 31 additions & 0 deletions tests/issues/Issue9.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package issues;
import utest.*;

class Issue9 extends Test {

public var array = [1,2,3];

function testIssue5 () {
new A(this);
}

}

@:yield
class A {

private var external:Issue9;

public function new(v) {
external = v;
iterator().next();
Assert.pass();
}

function iterator() : Iterator<Dynamic>
{
for (i in external.array) {}

@yield break;
}
}
8 changes: 5 additions & 3 deletions yield/generators/DefaultGenerator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,14 @@ class DefaultGenerator {
if (_data.names[0] == null) {
eRef.expr = EField( {expr: EConst(CIdent('this')), pos: eRef.pos}, parentFieldName );
} else {


var fieldName:String = NameController.localVar(_data.names[0], _defData.scope, _defData.channel, _defData.env.getParentCount() + 1);

var lfield:Expr = {
expr: EField({
expr: EField( {expr: EConst(CIdent('this')), pos: eRef.pos}, parentFieldName ),
pos : eRef.pos
}, _data.names[0] ),
}, fieldName ),
pos: eRef.pos
};

Expand Down Expand Up @@ -954,7 +956,7 @@ class DefaultGenerator {
#end;
return mapping == null ? e : macro @:pos(e.pos) @:mergeBlock {
$mapping;
$e;
${{ expr: e.expr, pos: e.pos }};
};
}

Expand Down

0 comments on commit 26e9e08

Please sign in to comment.