mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Improve error when generating first enum member of non-scalar type
This commit is contained in:
parent
05ab31df42
commit
f758043e18
2 changed files with 8 additions and 3 deletions
|
@ -2528,9 +2528,14 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
||||||
if (!em.ed.isAnonymous())
|
if (!em.ed.isAnonymous())
|
||||||
em.ed.memtype = t;
|
em.ed.memtype = t;
|
||||||
}
|
}
|
||||||
|
const errors = global.startGagging();
|
||||||
Expression e = new IntegerExp(em.loc, 0, t);
|
Expression e = new IntegerExp(em.loc, 0, t);
|
||||||
e = e.ctfeInterpret();
|
e = e.ctfeInterpret();
|
||||||
|
if (global.endGagging(errors))
|
||||||
|
{
|
||||||
|
error(em.loc, "cannot generate 0 value of type `%s` for `%s`",
|
||||||
|
t.toChars(), em.toChars());
|
||||||
|
}
|
||||||
// save origValue for better json output
|
// save origValue for better json output
|
||||||
em.origValue = e;
|
em.origValue = e;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/diag7477.d(13): Error: integral constant must be scalar type, not `Foo`
|
fail_compilation/diag7477.d(13): Error: cannot generate 0 value of type `Foo` for `a`
|
||||||
fail_compilation/diag7477.d(20): Error: integral constant must be scalar type, not `string`
|
fail_compilation/diag7477.d(20): Error: cannot generate 0 value of type `string` for `a`
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue