[Issue 5373] New: Regression (2.051) CTFE and std.string.replace() causes "Bad binary function q{a == b}..
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 24 21:33:05 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5373
Summary: Regression (2.051) CTFE and std.string.replace()
causes "Bad binary function q{a == b}..
Product: D
Version: D2
Platform: Other
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: soul8o8 at gmail.com
--- Comment #0 from Heywood Floyd <soul8o8 at gmail.com> 2010-12-24 21:31:04 PST ---
Using replace() in a mixin doesn't seem to work if the mixin is placed inside a
class. (I have no idea what's going on here.)
Isolated example:
// - - - - 8< - - - - - - - - - - - -
import std.stdio, std.string;
version(bug)
{
class Foo
{
mixin(anint("a"));
this()
{
a = 9;
}
}
}
void main()
{
version(bug)
{
auto a = new Foo;
writeln("a:", a.a);
}
else //works
{
mixin(anint("a"));
a = 9;
writeln("a:",a);
}
}
string anint(string name)
{
return replace("int $name;", "$name", name);
}
// - - - - 8< - - - - - - - - - - - -
# dmd -run testmixin.d
a:9
# dmd -version=bug -run testmixin.d
/Library/Compilers/dmd2/osx/bin/../../src/phobos/std/functional.d(177): Error:
static assert "Bad binary function q{a == b}. You need to use a valid D
expression using symbols a of type dchar and b of type const(char)[]."
/Library/Compilers/dmd2/osx/bin/../../src/phobos/std/functional.d(180):
instantiated from here: Body!(dchar,const(char)[])
/Library/Compilers/dmd2/osx/bin/../../src/phobos/std/algorithm.d(2149):
instantiated from here: result!(dchar,const(char)[])
# _
// - - - - 8< - - - - - - - - - - - -
I'm pretty sure this worked in 2.050, or at least 2.049. (Some program I'm
working on started emitting these errors today. Didn't before. Not entirely
sure when I last built it. Sorry.)
BR
/HF
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list