Thread overview
[Issue 8285] New: ParameterStorageClassTuple fails in CTFE
Jun 22, 2012
Max Samukha
Re: [Issue 8285] Error passing CTFE-generated string slice to template value parameter
Jun 24, 2012
Max Samukha
Jun 25, 2012
Max Samukha
Jun 26, 2012
kenji hara
Jul 03, 2012
Max Samukha
Jul 03, 2012
Max Samukha
[Issue 8285] Issue with slice returned from CTFE function
Aug 23, 2012
Don
Jul 14, 2013
yebblies
June 22, 2012
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


--- Comment #0 from Max Samukha <samukha@voliacable.com> 2012-06-22 10:42:33 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: -------
June 24, 2012
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
June 25, 2012
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

June 26, 2012
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
>
July 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8285



--- Comment #1 from Max Samukha <samukha@voliacable.com> 2012-07-02 23:33:55 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: -------
July 03, 2012
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?
August 23, 2012
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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-08-23 01:49:22 PDT ---
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: -------
July 12, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8285



--- Comment #3 from github-bugzilla@puremagic.com 2013-07-12 14:07:19 PDT ---
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 Merge pull request #2339 from donc/fourCTFEtestcases

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: -------
July 14, 2013
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: -------