Permalink
Browse files

Merge pull request #498 from 9rnsr/fix6902

Issue 6902 - Different "pure nothrow int()" types
  • Loading branch information...
2 parents 6fb5861 + fbd805f commit 3af76245c7626a1489322bb6fc8353b1c4aa2e35 @WalterBright WalterBright committed Nov 14, 2011
Showing with 29 additions and 2 deletions.
  1. +7 −1 src/func.c
  2. +1 −1 src/statement.c
  3. +21 −0 test/runnable/xtest46.d
View
@@ -1291,7 +1291,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (!type->nextOf())
{
((TypeFunction *)type)->next = Type::tvoid;
- type = type->semantic(loc, sc);
+ //type = type->semantic(loc, sc); // Removed with 6902
}
f = (TypeFunction *)type;
}
@@ -1697,6 +1697,12 @@ void FuncDeclaration::semantic3(Scope *sc)
f->trust = TRUSTsafe;
}
+ // Do semantic type AFTER pure/nothrow inference.
+ if (inferRetType)
+ {
+ type = type->semantic(loc, sc);
+ }
+
if (global.gag && global.errors != nerrors)
semanticRun = PASSsemanticdone; // Ensure errors get reported again
else
View
@@ -3618,7 +3618,7 @@ Statement *ReturnStatement::semantic(Scope *sc)
tf->isref = FALSE; // return by value
}
tf->next = exp->type;
- fd->type = tf->semantic(loc, sc);
+ //fd->type = tf->semantic(loc, sc); // Removed with 6902
if (!fd->tintro)
{ tret = fd->type->nextOf();
tbret = tret->toBasetype();
@@ -4021,6 +4021,26 @@ void test6910()
}
/***************************************************/
+// 6902
+
+void test6902()
+{
+ static assert(is(typeof({
+ return int.init; // int, long, real, etc.
+ })));
+
+ int f() pure nothrow { assert(0); }
+ alias int T() pure nothrow;
+ static if(is(typeof(&f) DT == delegate))
+ {
+ static assert(is(DT* == T*)); // ok
+
+ // Error: static assert (is(pure nothrow int() == pure nothrow int())) is false
+ static assert(is(DT == T));
+ }
+}
+
+/***************************************************/
int main()
{
@@ -4215,6 +4235,7 @@ int main()
test6813();
test6859();
test6910();
+ test6902();
printf("Success\n");
return 0;

0 comments on commit 3af7624

Please sign in to comment.