www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10503] New: Octal enums don't work anymore

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503

           Summary: Octal enums don't work anymore
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: hsteoh quickfur.ath.cx


--- Comment #0 from hsteoh quickfur.ath.cx 2013-06-29 10:47:52 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning still-hidden.de


--- Comment #1 from Henning Pohl <henning still-hidden.de> 2013-06-29 11:37:12
PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-06-29
12:12:39 PDT ---
(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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503


Adam D. Ruppe <destructionator gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator gmail.com


--- Comment #3 from Adam D. Ruppe <destructionator gmail.com> 2013-06-29
12:14:31 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503



--- Comment #4 from Henning Pohl <henning still-hidden.de> 2013-06-29 12:27:33
PDT ---
Guess you are right. I'm working on this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503



--- Comment #5 from hsteoh quickfur.ath.cx 2013-06-29 13:23:36 PDT ---
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).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #6 from Henning Pohl <henning still-hidden.de> 2013-06-29 13:43:29
PDT ---
https://github.com/D-Programming-Language/dmd/pull/2277

Kind of dirty fix, but it will do it for now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503



--- Comment #7 from Kenji Hara <k.hara.pg gmail.com> 2013-06-30 01:07:00 PDT ---
(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 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503



--- Comment #8 from github-bugzilla puremagic.com 2013-06-30 03:28:34 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10503


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2013