Bug 21839 – Strange output at Compile time

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2021-04-17T16:59:39Z
Last change time
2021-04-17T18:35:29Z
Assigned to
No Owner
Creator
Menshikov Konstantin

Comments

Comment #0 by mensikovk817 — 2021-04-17T16:59:39Z
import std.stdio; alias Sample = inter!q{ void sample(); }; void main(){} template inter(string a){ enum inter = { struct Dummy{mixin(a);} foreach(member_name; __traits(allMembers, Dummy)){ if(member_name != `this`){ pragma(msg, "WHYYYY ", member_name != `this`); } } return 0; }(); } output: WHYYYY true WHYYYY false version: DMD32 D Compiler v2.096.0-dirty
Comment #1 by dlang-bugzilla — 2021-04-17T17:11:48Z
What output are you expecting/ (In reply to Menshikov Konstantin from comment #0) > if(member_name != `this`){ Did you mean to use "static if" instead of "if"?
Comment #2 by boris2.9 — 2021-04-17T18:35:29Z
Nested structs have a hidden 'this' pointer to the enclosing context. It seems isn't that hidden after all.