Bug 10503 – Octal enums don't work anymore

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-29T10:47:00Z
Last change time
2013-06-30T06:05:41Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2013-06-29T10:47:52Z
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).
Comment #6 by henning — 2013-06-29T13:43:29Z
https://github.com/D-Programming-Language/dmd/pull/2277 Kind of dirty fix, but it will do it for now.
Comment #7 by k.hara.pg — 2013-06-30T01:07:00Z
(In reply to comment #6) > https://github.com/D-Programming-Language/dmd/pull/2277 > > Kind of dirty fix, but it will do it for now. I opened another fix that I think clean. https://github.com/D-Programming-Language/dmd/pull/2279
Comment #8 by github-bugzilla — 2013-06-30T03:28:34Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f88c75f17dcc25ace5d8a52a4a9f5e6d301ad8a4 fix Issue 10503 - Octal enums don't work anymore https://github.com/D-Programming-Language/dmd/commit/e8c76cdd192676613a37b5faaf7f3d6c758ef42d Merge pull request #2279 from 9rnsr/fix10503 [REG2.064a] Issue 10503 - Octal enums don't work anymore