Bug 6970 – Pseudo Members

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2011-11-18T04:07:00Z
Last change time
2011-11-18T07:33:09Z
Assigned to
nobody
Creator
a11160678

Comments

Comment #0 by a11160678 — 2011-11-18T04:07:45Z
According to TDPL, 5.9.1 "Pseudo Members and the @property Attribute", D allows pseudo-member notation: "if a.fun(b,c,d) is seen but fun is not a member of a's type, D rewrites that as fun(a,b,c,d) and tries that as well." Apparantly this is only true for arrays, and even for arrays it does not work in some cases: void gun(ref int[]) { } void sun(ref int[], int v) { } int[] global; ref int[] fun() { return global; } @property ref int[] funProp() { return global; } void main() { gun(global); // works sun(global, 0); // works global.gun; // works (but shouldn't ?) global.gun(); // works global.sun(0); // works fun().gun; // works (but shouldn't ?) fun().gun(); // works fun().sun(0); // works funProp.gun; // works (but shouldn't ?) funProp.gun(); // does not work but should funProp.sun(0); // does not work but should }
Comment #1 by bus_dbugzilla — 2011-11-18T07:33:09Z
Duplicate of issue 3382, issue 2883, and issue 662 *** This issue has been marked as a duplicate of issue 3382 ***