[Issue 12533] New: instantiated template using __traits(compiles, ...) causes semantic errors when reused
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 6 16:39:51 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12533
Summary: instantiated template using __traits(compiles, ...)
causes semantic errors when reused
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: 2krnk at gmx.net
--- Comment #0 from det <2krnk at gmx.net> 2014-04-06 16:39:50 PDT ---
compilation fails for no reason in given example involving a template using
mixin, static if and __traits(compiles, ...) code reflection. see details in
example as it is too complicated to describe.
might be related to issue 12532. however, example fails as well when 'enum' is
replaced by 'const'
=== EXAMPLE ===
template valid(string mem){
pragma(msg, "instantiation of valid with: "~mem);
static if( !__traits( compiles, mixin(mem) ) ){
enum valid = false;
}else{
enum valid = true;
}
}
enum works = valid!"fails";
pragma(msg, "found 'fails' (via 'works')? "~works.stringof );
// compiles but produces 'false': issue 12532
enum dummy = valid!"fails";
pragma(msg, "found 'fails' (via 'dummy')? "~dummy.stringof );
// compiles but produces 'false': issue 12532
enum fails = valid!"fails";
// Error: variable demo.fails had semantic errors when compiling
// NOTE: if you comment out the first two usages of valid!"fails",
// it will work here - but give 'false' again.
// pragma(msg, "found 'fails' (via 'fails')? "~fails.stringof );
void main(){}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list