[Issue 16301] New: CTFE execution of opApply keeps wrong "this" context in foreach's body
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 20 01:34:46 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16301
Issue ID: 16301
Summary: CTFE execution of opApply keeps wrong "this" context
in foreach's body
Product: D
Version: D2
Hardware: All
URL: http://dlang.org/
OS: All
Status: NEW
Severity: enhancement
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
struct OpApply {
int opApply(scope int delegate(int) dlg) {
return dlg(1);
}
}
struct Foo {
int i;
this(int x) {
foreach(_; OpApply()) {
i = 0; // Error: couldn't find field i of type int in OpApply()
}
}
}
enum x = Foo(1);
(also happens with this.i = 0).
--
More information about the Digitalmars-d-bugs
mailing list