www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8285] New: ParameterStorageClassTuple fails in CTFE

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

           Summary: ParameterStorageClassTuple fails in CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: samukha voliacable.com



PDT ---
import std.traits;

string bar(T)()
{
    alias ParameterStorageClassTuple!(T) scs;
    return "";
}

string foo(string attrs)
{
    return "";
}

alias ref int function() Fn;
enum baz2 = foo(bar!Fn());


\phobos\std\traits.d(99): Error: expression "NcZi"c[2u..4u] is not a valid
template value argument

This is the smallest case I have for now. Still trying to narrow it further.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2012
next sibling parent reply "Max Samukha" <maxsamukha gmail.com> writes:
Reduced test case:

string foo()
{
      string s = "ab";
      return s[0 .. $];
}

template T2(string s)
{
}

template T1()
{
      enum s = foo();
      alias T2!(s) t2;
}

int bar()
{
      alias T1!() t1;
      return 0;
}

int baz(int x)
{
      return 0;
}

static assert(baz(bar()) == 0);

void main()
{
}

Error: expression "ab"[0u..2u] is not a valid template value
argument
Jun 24 2012
parent reply "Max Samukha" <maxsamukha gmail.com> writes:
Another test case. The error is different but the root cause must 
be the same.

string bar()
{
     string s = "ab";
     return s[0..$];
}

template T1()
{
     enum T1 = bar()[0..$]; // error
}

string baz()
{
     return T1!();
}

string foo(string s)
{
     return s;
}

static assert(foo(baz()) == "ab");

void main()
{
}

Error: variable __dollar cannot be read at compile time
Jun 25 2012
parent reply kenji hara <k.hara.pg gmail.com> writes:
Direct replying to this news group/mailing list is no meaning.
You must post these test case from the form in bugzilla.

http://d.puremagic.com/issues/show_bug.cgi?id=3D8285

Kenji hara

2012/6/25 Max Samukha <maxsamukha gmail.com>:
 Another test case. The error is different but the root cause must be the
 same.

 string bar()

 {
 =C2=A0 =C2=A0string s =3D "ab";
 =C2=A0 =C2=A0return s[0..$];
 }

 template T1()
 {
 =C2=A0 =C2=A0enum T1 =3D bar()[0..$]; // error
 }

 string baz()
 {
 =C2=A0 =C2=A0return T1!();
 }

 string foo(string s)
 {
 =C2=A0 =C2=A0return s;
 }

 static assert(foo(baz()) =3D=3D "ab");

 void main()
 {
 }

 Error: variable __dollar cannot be read at compile time
Jun 25 2012
parent "Max Samukha" <maxsamukha gmail.com> writes:
On Tuesday, 26 June 2012 at 16:27:29 UTC, kenji hara wrote:
 Direct replying to this news group/mailing list is no meaning.
 You must post these test case from the form in bugzilla.

 http://d.puremagic.com/issues/show_bug.cgi?id=8285

 Kenji hara

 2012/6/25 Max Samukha <maxsamukha gmail.com>:
 Another test case. The error is different but the root cause 
 must be the
 same.

 string bar()

 {
    string s = "ab";
    return s[0..$];
 }

 template T1()
 {
    enum T1 = bar()[0..$]; // error
 }

 string baz()
 {
    return T1!();
 }

 string foo(string s)
 {
    return s;
 }

 static assert(foo(baz()) == "ab");

 void main()
 {
 }

 Error: variable __dollar cannot be read at compile time
For some brain glitch reason, I was sure I was posting to bugzilla. Sorry for that. Why not configure this group so that it refuses direct posts or issues warnings?
Jul 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8285




PDT ---
Test case 1:

string foo()
{
     string s = "ab";
     return s[0 .. $];
}

template T2(string s)
{
}

template T1()
{
     enum s = foo();
     alias T2!(s) t2;
}

int bar()
{
     alias T1!() t1;
     return 0;
}

int baz(int x)
{
     return 0;
}

static assert(baz(bar()) == 0);

void main()
{
}

Error: expression "ab"[0u..2u] is not a valid template value
argument

Test case 2:

string bar()
{
    string s = "ab";
    return s[0..$];
}

template T1()
{
    enum T1 = bar()[0..$]; // error
}

string baz()
{
    return T1!();
}

string foo(string s)
{
    return s;
}

static assert(foo(baz()) == "ab");

void main()
{
}

Error: variable __dollar cannot be read at compile time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8285


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
         Depends on|                            |7988



In the second example, adding the line

+ enum unused_enum = T1!();

string baz()
{
    return T1!();
}

makes the code work. It's because the const-folding code outside of CTFE is not
as sophisticated as the code inside CTFE.

Fixing bug 7988 would fix this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8285




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f5c5d43e35a48d6cc63a2fe05c68f8b88ef5e21d
Fix issue 8285 Issue with slice returned from CTFE function

Test case only; fixed by using CTFE to do constfolding.

https://github.com/D-Programming-Language/dmd/commit/a0ba3b2aa31d93709a1ed3e21f5a2deca6c761fc


Test cases for bugs 1982, 7988, 8253, and 8285.

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


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED


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