Bug 12056 – [CTFE] "couldn't find field" from delegate

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-01T10:44:32Z
Last change time
2024-12-13T18:16:34Z
Keywords
CTFE, rejects-valid
Assigned to
No Owner
Creator
Nils
Moved to GitHub: dmd#17637 →

Comments

Comment #0 by nilsbossung — 2014-02-01T10:44:32Z
--- cat > test.d << code struct A { void call(void delegate() dg) {dg();} } struct B { int f; void m() { A a; a.call({auto err = f;}); } } bool go() { B b; b.m(); return true; } static assert(go()); code dmd -c test.d --- test.d(12): Error: couldn't find field f of type int in A() test.d(3): called from here: dg() test.d(12): called from here: a.call(delegate () { int err = this.f; } ) test.d(19): called from here: b.m() test.d(23): called from here: go() test.d(23): while evaluating: static assert(go()) --- The error message says "couldn't find field [...] in A()", when the field should be looked up in B. The error remains the same even when a field f is added to A. This also affects opApply.
Comment #1 by k.hara.pg — 2015-07-09T04:37:16Z
Related issue: 9541
Comment #2 by robert.schadek — 2024-12-13T18:16:34Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17637 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB