Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[Repost] Issue 8220 - invalid function call not detected during semantic analysis #1007

Merged
merged 1 commit into from

4 participants

@9rnsr
Collaborator

http://d.puremagic.com/issues/show_bug.cgi?id=8220

This pull is identical to #1000. @WalterBright reverted #1000, because of the breaking of test case that he has, but I think it is genuinely invalid code (my comment).

@donc
Collaborator

I agree with you. I have written code like Walter's example in the past, and I later rewrote it because I decided it was wrong. int + int isn't valid, and typeof(int + int) shouldn't be, either. It's easy enough to add .init to every type to turn those into valid expressions. It's not like it's a silent breakage.

But only Walter can merge this.

@ghost

LGTM. @WalterBright please merge this before any more people start assuming that Type+Type is meaningful (6 months and counting!). AFAIK the specs never mention this as valid code, but you've said you told some people it does work. Couldn't you tell them about .init?

@WalterBright WalterBright merged commit 3644943 into D-Programming-Language:master
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +3 −0  src/expression.c
  2. +6 −0 test/runnable/xtest46.d
View
3  src/expression.c
@@ -723,6 +723,9 @@ void preFunctionParameters(Loc loc, Scope *sc, Expressions *exps)
#endif
(*exps)[i] = arg;
+ if (arg->op == TOKtype)
+ arg->error("%s is not an expression", arg->toChars());
+
//arg->rvalue();
#if 0
if (arg->type->ty == Tfunction)
View
6 test/runnable/xtest46.d
@@ -5137,6 +5137,12 @@ void test8064()
}
/***************************************************/
+// 8220
+
+void foo8220(int){}
+static assert(!__traits(compiles, foo8220(typeof(0)))); // fail
+
+/***************************************************/
void func8105(in ref int x) { }
Something went wrong with that request. Please try again.