www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11504] New: [CTFE] JSONValue cannot make in CTFE

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

           Summary: [CTFE] JSONValue cannot make in CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: zan77137 nifty.com



import std.json;

JSONValue foo()
{
    JSONValue v;
    v.integer = 1;
    return v;
}

void main(string[] args)
{
    enum v1 = foo(); // 2.064.2 OK -> 2.065a NG
    auto v2 = foo(); // OK
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504


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

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



07:59:57 PST ---
What exactly is the problem? There's an exception thrown:

std\json.d(765): Error: Uncaught CTFE exception
std.json.JSONException("JSONValue is not an integer")
test.d(6):        thrown from here
test.d(12):        called from here: foo()

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504




Quite honestly, the behavior that this code makes the compilation error by the
exception in CTFE is a destructive change, but thinks that I can permit it.
The big problem is that even if every other methods, union (JSONValue.Store)
cannot be initialized.
The reason why the code mentioned above was OK in the past is a thing by the
bugs of the compilers. (SeeAlso: Issue11427
This problem is settled by supporting union formally in CTFE.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |11510




 This problem is settled by supporting union formally in CTFE.
For that, I posted a compiler enhancement issue 11510. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504




10:24:30 PST ---

 The reason why the code mentioned above was OK in the past is a thing by the
 bugs of the compilers. (SeeAlso: Issue11427
std.json was refactored a while ago and it might be the cause of this regression. But I still don't understand what the problem is with this code *right now*. Can anyone try to explain what SHOO meant in plain English? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE
          Component|Phobos                      |DMD





 The reason why the code mentioned above was OK in the past is a thing by the
 bugs of the compilers. (SeeAlso: Issue11427
std.json was refactored a while ago and it might be the cause of this regression. But I still don't understand what the problem is with this code *right now*. Can anyone try to explain what SHOO meant in plain English?
I separately filed the true std.json regression as issue 11527. After fixing the bug, the OP case will print following errors. C:\dmd2\src\phobos\std\json.d(181): Error: Unions with overlapping fields are not yet supported in CTFE C:\dmd2\src\phobos\std\json.d(103): called from here: this.assign(v) test.d(6): called from here: v.integer(1L) test.d(12): called from here: foo() The error is caused by issue 11510, and could be fixed by my compiler enhancement fix. I change this to dmd issue. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504


John Colvin <john.loughran.colvin gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin gmail.
                   |                            |com



12:50:11 GMT ---



 The reason why the code mentioned above was OK in the past is a thing by the
 bugs of the compilers. (SeeAlso: Issue11427
std.json was refactored a while ago and it might be the cause of this regression. But I still don't understand what the problem is with this code *right now*. Can anyone try to explain what SHOO meant in plain English?
I separately filed the true std.json regression as issue 11527.
I would argue that is not necessarily a bug. See my comments in issue 11527 and https://github.com/D-Programming-Language/phobos/pull/1693 https://d.puremagic.com/issues/show_bug.cgi?id=11510 is the real problem here, as you rightly point out. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11504


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



Issue 10527 has been fixed. So add a link to pull request.

https://github.com/D-Programming-Language/dmd/pull/2757

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2013