Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 9312 - With statement diagnostic is wrong #1479

Merged
merged 1 commit into from

1 participant

@ghost

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

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
@ghost

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
@9rnsr
Collaborator

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?

@ghost

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

@9rnsr
Collaborator

LGTM.

@9rnsr 9rnsr merged commit 6cfa082 into from
@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
Commits on Jan 14, 2013
  1. Fixes Issue 9312 - With diagnostic is wrong.

    Andrej Mitrovic authored
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 1 deletion.
  1. +1 −1  src/statement.c
  2. +13 −0 test/fail_compilation/diag9312.d
View
2  src/statement.c
@@ -4538,7 +4538,7 @@ Statement *WithStatement::semantic(Scope *sc)
sym->parent = sc->scopesym;
}
else
- { 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;
}
}
View
13 test/fail_compilation/diag9312.d
@@ -0,0 +1,13 @@
+/*
+TEST_OUTPUT:
+---
+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.