Skip to content

Commit

Permalink
Fixes issue #178 (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlavaRa authored Aug 23, 2016
1 parent 3ef91ae commit 6a316b2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/as3hx/Writer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1886,8 +1886,9 @@ class Writer
if (conds[0].match(EBinop("&&" | "||", _, _, _))) return true;
//index must be incremented by 1
if (incrs.length == 1) {
return switch (incrs[0]) {
return switch(incrs[0]) {
case EUnop(op, _, _): op != "++";
case EBinop(openb,_,_,_): true;
default: false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/as3hx/parsers/TypeParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class TypeParser {
case TDot:
tk = tokenizer.token();
switch(ParserUtils.uncomment(tk)) {
case TId(id): a.push(id);
default: ParserUtils.unexpected(ParserUtils.uncomment(tk));
case TId(id): a.push(id);
default: ParserUtils.unexpected(ParserUtils.uncomment(tk));
}
case TCommented(s,b,t):

Expand Down
9 changes: 9 additions & 0 deletions test/issues/Issue178.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package {
public class Issue178 {
public function Issue178() {
for (var i:int = 0; i < 10; i+=2) {
trace(i);
}
}
}
}
13 changes: 13 additions & 0 deletions test/issues/Issue178.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

class Issue178
{
public function new()
{
var i : Int = 0;
while (i < 10)
{
trace(i);
i += 2;
}
}
}
5 changes: 5 additions & 0 deletions test/unit/as3hx/AS3HXTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class AS3HXTest {
generate("Issue176.as", "Issue176.hx");
}

@Test
public function issue178() {
generate("Issue178.as", "Issue178.hx");
}

function generate(as3FileName:String, expectedHaxeFileName:String) {
var issuesDirectory = FileSystem.absolutePath("test/issues");
var generatedDirectoryPath = '$issuesDirectory/generated';
Expand Down

0 comments on commit 6a316b2

Please sign in to comment.