Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 15239 - ICE (assertion failure) in ctfeInterpret() - opDispatch & inline asm #5263

Merged
merged 2 commits into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -5252,12 +5252,12 @@ extern (C++) final class ScopeExp : Expression
public:
ScopeDsymbol sds;

extern (D) this(Loc loc, ScopeDsymbol pkg)
extern (D) this(Loc loc, ScopeDsymbol sds)
{
super(loc, TOKimport, __traits(classInstanceSize, ScopeExp));
//printf("ScopeExp::ScopeExp(pkg = '%s')\n", pkg->toChars());
//printf("ScopeExp::ScopeExp(sds = '%s')\n", sds.toChars());
//static int count; if (++count == 38) *(char*)0=0;
this.sds = pkg;
this.sds = sds;
}

override Expression syntaxCopy()
Expand All @@ -5271,8 +5271,8 @@ public:
{
printf("+ScopeExp::semantic(%p '%s')\n", this, toChars());
}
//if (type == Type::tvoid)
// return this;
if (type)
return this;

ScopeDsymbol sds2 = sds;
TemplateInstance ti = sds2.isTemplateInstance();
Expand Down Expand Up @@ -5312,6 +5312,9 @@ public:
return e.semantic(sc);
}
}
// ti is an instance which requires IFTI.
sds = ti;
type = Type.tvoid;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in particular changed the semantic of typeof(func!arg) from Error: expression (func!arg) has no type to plain void. I think it's incorrect to type a not fully instantiated template function as void (even though there is some precedence w/ templates being of type void).
For non-function templates it's an error when arguments are missing and even with this change typeof(&func!arg) triggers the same error.
On top of this all this change broken is(typeof(T.someAttribute)) detection for types w/ opDispatch.

return this;
}
ti.semantic(sc);
Expand Down Expand Up @@ -8897,7 +8900,7 @@ public:
/* This recognizes:
* foo!(tiargs)(funcargs)
*/
if (e1.op == TOKimport && !e1.type)
if (e1.op == TOKimport)
{
ScopeExp se = cast(ScopeExp)e1;
TemplateInstance ti = se.sds.isTemplateInstance();
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/fail10481.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TEST_OUTPUT:
---
fail_compilation/fail10481.d(11): Error: undefined identifier 'T1', did you mean alias 'T0'?
fail_compilation/fail10481.d(15): Error: cannot resolve type for get!(A)
fail_compilation/fail10481.d(15): Error: cannot infer type from template instance get!(A)
---
*/

Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/ice15239.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice15239.d(21): Error: cannot interpret opDispatch!"foo" at compile time
fail_compilation/ice15239.d(21): Error: bad type/size of operands '__error'
---
*/

struct T
{
template opDispatch(string Name, P...)
{
static void opDispatch(P) {}
}
}

void main()
{
asm
{
call T.foo;
}
}