CODE:
=============================
import std.conv;
enum {
A = octal!"2000000",
B = octal!"4000"
}
void main() {
}
=============================
DMD git HEAD:
=============================
test.d(4): Error: cannot implicitly convert expression (octal) of type pure nothrow @property @safe int() to pure nothrow @property @safe int()
=============================
git bisect shows that the offending commit was 88ebe192d605bd8d4b5768e8a2500f54d73fb5fd
Comment #1 by henning — 2013-06-29T11:37:12Z
You need to execute octal by using parentheses:
import std.conv;
enum {
A = octal!"2000000"(),
B = octal!"4000"()
}
void main() {
}
As the compiler has mentioned, what you have actually been doing is passing functions instead of their result when executed.
What you could possibly do to avoid these parentheses is using eponymous templates.
Comment #2 by andrej.mitrovich — 2013-06-29T12:12:39Z
(In reply to comment #1)
> You need to execute octal by using parentheses.
No you don't, this is a breaking change that needs to be fixed. octal has always been used like this.
Comment #3 by destructionator — 2013-06-29T12:14:31Z
octal isn't even a function, I thought. It uses a helper function internally, but in the end does an
template octal(s) {
enum octal = helper(s);
}
so calling it on the outside world isn't right - octal!100 should be an int literal.
Comment #4 by henning — 2013-06-29T12:27:33Z
Guess you are right. I'm working on this.
Comment #5 by hsteoh — 2013-06-29T13:23:36Z
This problem only happens when the enum has two members. Manifest constants and single-member enums work fine. So it's definitely a bug (inconsistent behaviour between single-member and multi-member enums).