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



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



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



12:12:39 PDT ---

 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



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




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




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



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





 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




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


[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