Skip to content

Commit

Permalink
issues #81 and #82
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdruppe committed Nov 1, 2024
1 parent f834361 commit 0f83714
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
8 changes: 7 additions & 1 deletion compiler/src/dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t)
auto tmp = new VarDeclaration(e.loc, t, Identifier.generateId("__ictorcmp"), null);
tmp.dsymbolSemantic(sc);

Expression decl = new DeclarationExp(e.loc, tmp);
decl = decl.expressionSemantic(sc);

Expression ve = new VarExp(e.loc, tmp);
Expression e2 = new DotIdExp(e.loc, ve, Id.ctor);
auto ce = new CallExp(e.loc, e2, e);
e2 = ce;

auto declareTmps = new CommaExp(e.loc, decl, e2);

if (sc && .trySemantic(e2, sc)) {
if (hasImplicitAttr(ce.f)) {
result = e2.expressionSemantic(sc);
result = declareTmps.expressionSemantic(sc);
// printf("implicit construction of %s @ %s\n", t.toChars(), e.loc.toChars());
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -3651,7 +3651,7 @@ FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymbol s,
{
errorSupplemental(loc, "%s `%s` hides interface function `%s`",
fd.kind, fd.toPrettyChars(), mErr.lastf.toPrettyChars());
errorSupplemental(loc, "add `alias %s = %s` to `%s`'s body to merge the overload sets",
errorSupplemental(loc, "add `alias %s = %s` to `%s`'s body to merge the overload sets or call `yourObject.DesiredInterface.func()` at the usage site", // FIXME make the suggestion better
fd.toChars(), mErr.lastf.toPrettyChars(), tthis.toChars());
return null;
}
Expand Down
44 changes: 28 additions & 16 deletions compiler/src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -629,22 +629,34 @@ extern (D) MATCH callMatch(TypeFunction tf, Type tthis, ArgumentList argumentLis

if (auto ad = isAggregate(p.type))
if (ad.hasImplicitConstructor()) {
auto tmp = new VarDeclaration(arg.loc, p.type, Identifier.generateId("__ictorcmp"), null);
tmp.storage_class = STC.rvalue | STC.temp | STC.ctfe;
tmp.dsymbolSemantic(sc);

Expression ve = new VarExp(arg.loc, tmp);
Expression e = new DotIdExp(arg.loc, ve, Id.ctor);
auto ce = new CallExp(arg.loc, e, arg);
e = ce;

//printf("%s to %s @ %s in %llx dddddddd\n", e.toChars(), p.type.toChars(), arg.loc.toChars(), cast(ulong)sc);
if (sc && .trySemantic(e, sc)) {
if (hasImplicitAttr(ce.f)) {
auto cast_m = argumentMatchParameter(tf, p, e, wildmatch, flag, sc, pMessage);
if (cast_m == MATCH.exact) {
// printf("ctor complete %s(%s) @ %s\n", p.type.toChars(), arg.toChars(), arg.loc.toChars());
m = MATCH.convert;

static int recursionCount;

recursionCount++;
scope(exit) recursionCount--;

// FIXME the recursionCount is about
// https://github.com/opendlang/opend/issues/81
// and i think the real cause is that this might also be trying to implicitly construct itself
if(recursionCount < 3) {

auto tmp = new VarDeclaration(arg.loc, p.type, Identifier.generateId("__ictorcmp"), null);
tmp.storage_class = STC.rvalue | STC.temp | STC.ctfe;
tmp.dsymbolSemantic(sc);

Expression ve = new VarExp(arg.loc, tmp);
Expression e = new DotIdExp(arg.loc, ve, Id.ctor);
auto ce = new CallExp(arg.loc, e, arg);
e = ce;

//printf("%s to %s @ %s in %llx dddddddd\n", e.toChars(), p.type.toChars(), arg.loc.toChars(), cast(ulong)sc);
if (sc && .trySemantic(e, sc)) {
if (hasImplicitAttr(ce.f)) {
auto cast_m = argumentMatchParameter(tf, p, e, wildmatch, flag, sc, pMessage);
if (cast_m == MATCH.exact) {
// printf("ctor complete %s(%s) @ %s\n", p.type.toChars(), arg.toChars(), arg.loc.toChars());
m = MATCH.convert;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions opend/src/opend.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import std.process;
import std.file;

// FIXME: when we call spawnProcess it doesn't print an error (though it does return a code) when the process segfaults.

int main(string[] args) {
// maybe override the normal config files
// --opend-config-file
Expand Down

0 comments on commit 0f83714

Please sign in to comment.