Skip to content

Commit 0b10f74

Browse files
committed
Fix bugs found testing on druntime and phobos
1 parent 2a72262 commit 0b10f74

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/dfix.d

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ int main(string[] args)
5353
}
5454

5555
foreach (f; parallel(files))
56-
upgradeFile(f, dip64, dip65);
56+
{
57+
try
58+
upgradeFile(f, dip64, dip65);
59+
catch (Throwable th)
60+
stderr.writeln("Failed to upgrade ", f, ":(", th.file, ":", th.line, ") ", th.msg);
61+
}
62+
5763

5864
return 0;
5965
}
@@ -126,7 +132,7 @@ void upgradeFile(string fileName, bool dip64, bool dip65)
126132
case bodyEnd:
127133
if (tokens[i].index != marker.index)
128134
break;
129-
assert (tokens[i].type == tok!"}");
135+
assert (tokens[i].type == tok!"}", format("%d %s", tokens[i].line, str(tokens[i].type)));
130136
writeToken(output, tokens[i]);
131137
i++;
132138
if (i < tokens.length && tokens[i] == tok!";")
@@ -201,6 +207,9 @@ void upgradeFile(string fileName, bool dip64, bool dip65)
201207
}
202208
}
203209

210+
if (i >= tokens.length)
211+
break;
212+
204213
switch (tokens[i].type)
205214
{
206215
case tok!"asm":
@@ -568,8 +577,11 @@ class DFixVisitor : ASTVisitor
568577
// enum body closing braces
569578
override void visit(const EnumBody enumBody)
570579
{
571-
markers ~= SpecialMarker(SpecialMarkerType.bodyEnd, enumBody.endLocation);
572580
enumBody.accept(this);
581+
// skip over enums whose body is a single semicolon
582+
if (enumBody.endLocation == 0 && enumBody.startLocation == 0)
583+
return;
584+
markers ~= SpecialMarker(SpecialMarkerType.bodyEnd, enumBody.endLocation);
573585
}
574586

575587
// Confusing placement of function attributes

0 commit comments

Comments
 (0)