digitalmars.D.bugs - [Issue 2157] New: mixin struct, function overload
- d-bugmail puremagic.com (37/37) Jun 20 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2157
- d-bugmail puremagic.com (10/10) Nov 24 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2157
- d-bugmail puremagic.com (30/30) Dec 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2157
- d-bugmail puremagic.com (29/34) Dec 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2157
http://d.puremagic.com/issues/show_bug.cgi?id=2157
Summary: mixin struct, function overload
Product: D
Version: 2.013
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: someanon yahoo.com
$ dmd mixinstruct.d
mixinstruct.d(15): function mixinstruct.S.attr (int) does not match parameter
types ()
mixinstruct.d(15): Error: s.attr can only be called on a mutable object, not
const(S)
mixinstruct.d(15): Error: expected 1 arguments, not 0
mixinstruct.d(15): Error: expression s.attr() is void and has no value
$ cat mixinstruct.d
==============================================================
template T() {
int m_attr;
const {int attr() {return m_attr;}} // reader
}
struct S {
mixin T;
void attr(int n) {m_attr = n;} // writer
}
int main() {
const S s;
int r;
r = s.attr(); // why this resolve to the writer? but not the reader?
return r;
}
==============================================================
--
Jun 20 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2157
smjg iname.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |smjg iname.com
Keywords| |rejects-valid
OS/Version|Linux |All
On DMD 2.019 Windows, the errors are the same, except at line 14.
--
Nov 24 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2157
pompei2 gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pompei2 gmail.com
This is still an issue in dmd 2.057, tested with the following code:
mixin template EagerSingleton()
{
private this()
{
instance = this;
}
private static typeof(this) instance;
}
class NetworkPacketQueue
{
mixin EagerSingleton;
public this(string bla)
{
this();
}
}
void main()
{
new NetworkPacketQueue("Hey");
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 17 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2157
Kenji Hara <k.hara.pg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
This is not an issue.
http://d-programming-language.org/template-mixin.html
Mixin Scope
The declarations in a mixin are ‘imported’ into the surrounding scope. If
the name of a declaration in a mixin is the same as a declaration in the
surrounding scope, the surrounding declaration overrides the mixin one:
^^^^^^^^^
If you want to merge overloads, you can add alias declaration to do it.
template T() {
int m_attr;
const {int attr() {return m_attr;}}
}
struct S {
mixin T t;
void attr(int n) {m_attr = n;}
alias t.attr attr; // Merge overloads
}
int main() {
const S s;
int r;
r = s.attr();
return r;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 17 2011









d-bugmail puremagic.com 