Skip to content


Issue 9312 - With statement diagnostic is wrong #1479

merged 1 commit into from

2 participants


It only lists class and struct instances as possible expressions, but there are many more: class and struct types, template instances, enumerations, modules, etc. To avoid listing all possible types it's best to just state the type which can't be used.

@ghost ghost closed this

You know it can actually be many things: class instance, struct instance, class or struct type, enumeration type, template instance, module declaration.

I think it might be simpler if we just said with expression cannot be of type xyz.

@ghost ghost reopened this
D Programming Language member

I think we can summarize the set of class, struct, union, and interface to 'aggregate'.
How about with expressions must be aggregate objects, not xxx?


@9rnsr: Sure, that could work. Done.

D Programming Language member


@9rnsr 9rnsr merged commit 6cfa082 into D-Programming-Language:master

1 check passed

Details default Pass: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2013
  1. @AndrejMitrovic
Showing with 14 additions and 1 deletion.
  1. +1 −1 src/statement.c
  2. +13 −0 test/fail_compilation/diag9312.d
2 src/statement.c
@@ -4538,7 +4538,7 @@ Statement *WithStatement::semantic(Scope *sc)
sym->parent = sc->scopesym;
- { error("with expressions must be class objects, not '%s'", exp->type->toChars());
+ { error("with expressions must be aggregate types, not '%s'", exp->type->toChars());
return NULL;
13 test/fail_compilation/diag9312.d
@@ -0,0 +1,13 @@
+fail_compilation/diag9312.d(10): Error: with expressions must be aggregate types, not 'int'
+void main()
+ with (1)
+ {
+ }
Something went wrong with that request. Please try again.