Skip to content

Commit f9af3ac

Browse files
committed
fix implicit construction at ctfe
1 parent 6a87802 commit f9af3ac

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

compiler/src/dmd/dcast.d

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t)
142142
if (ad) {
143143
import dmd.identifier;
144144
import dmd.id;
145-
auto tmp = new VarDeclaration(e.loc, t, Identifier.generateId("__ictorcmp"), null);
145+
auto tmp = new VarDeclaration(e.loc, t, Identifier.generateId("__ictorcmp"), new ExpInitializer(e.loc, e));
146+
tmp.storage_class = STC.rvalue | STC.temp | STC.ctfe;
146147
tmp.dsymbolSemantic(sc);
147148

148149
Expression decl = new DeclarationExp(e.loc, tmp);
@@ -153,11 +154,13 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t)
153154
auto ce = new CallExp(e.loc, e2, e);
154155
e2 = ce;
155156

156-
auto declareTmps = new CommaExp(e.loc, decl, e2);
157+
//auto declareTmps = new CommaExp(e.loc, decl, e2);
157158

158159
if (sc && .trySemantic(e2, sc)) {
159160
if (hasImplicitAttr(ce.f)) {
160-
result = declareTmps.expressionSemantic(sc);
161+
//printf("implicit construction of %s @ %s\n", declareTmps.toChars(), e.loc.toChars());
162+
//printf("implicit construction of %s @ %s\n", decl.toChars(), e.loc.toChars());
163+
result = decl.expressionSemantic(sc);
161164
// printf("implicit construction of %s @ %s\n", t.toChars(), e.loc.toChars());
162165
return result;
163166
}

compiler/src/dmd/dinterpret.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5029,6 +5029,9 @@ public:
50295029
if (vd is null)
50305030
return false;
50315031

5032+
if(vd._init is null)
5033+
return false;
5034+
50325035
auto ei = vd._init.isExpInitializer();
50335036
if (ei is null)
50345037
return false;
@@ -6142,7 +6145,7 @@ public:
61426145
return;
61436146
}
61446147

6145-
import dmd.utils : arrayCastBigEndian;
6148+
import dmd.utils : arrayCastBigEndian;
61466149

61476150
auto str = arrayCastBigEndian(se.peekData(), sz);
61486151
emplaceExp!(StringExp)(pue, e1.loc, str, se.len / sz, cast(ubyte) sz);

0 commit comments

Comments
 (0)