June 25, 2005
# // WinXP SP2 with dmd v0.127
# // Bug: Scalars attributes causing no compile errors,
# //      when trying to override local functions.
# //      (Explained a little better below)
# // MinMax.d
#
# private import std.stdio;
# private import std.string;
#
# size_t min(in size_t x, in size_t y)
# { if (x > y) return y; else return x; }
#
# size_t max(in size_t x, in size_t y)
# { if (x > y) return x; else return y; }
#
# size_t length(in char[] s) { return s.length; }
#
# int main()
# {
#     writefln("min(10, 9)=%d", min(10, 9)); // OK
#     writefln("max(10, 9)=%d", cast(ulong)max(10, 9)); // OK
#     writefln("min(10, 9)=%d", cast(long)(.min(10, 9))); // OK
#     writefln("max(10, 9)=%d", (.max(10, 9))); // OK
#
#     /+
#      ' Follow errors occur when casting a function's return value which
#      ' happens to be spelled exactly the same as a scalars attributes and
#      ' the local scope function dot (period) is used between them.
#      '
#      ' Errors:
#      ' found '(' when expecting ','
#      ' found ')' when expecting ';' following 'statement'
#      +/
#     writefln("min(10, 9)=%f", cast(real).min(10, 9)); // Won't compile.
#     writefln("max(10, 9)=%f", cast(real).max(10, 9)); // Won't compile.
#     // Won't compile.
#     writefln("length=%d", cast(long).length(toString(min(10,9))));
#
#     return 0;
# }

Output:
--------
C:\dmd>dmd minmax.d
minmax.d(32): found '(' when expecting ','
minmax.d(32): found ')' when expecting ';' following 'statement'
minmax.d(33): found '(' when expecting ','
minmax.d(33): found ')' when expecting ';' following 'statement'
minmax.d(34): found '(' when expecting ','
minmax.d(34): found ')' when expecting ';' following 'statement'

C:\dmd>

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html