Jump to page: 1 27  
Page
Thread overview
Code behaves incorrectly if it is compiled in std.functional
Jun 05, 2015
Meta
Jun 05, 2015
krzaq
Jun 05, 2015
ketmar
Jun 05, 2015
anonymous
Jun 05, 2015
ketmar
Jun 05, 2015
anonymous
Jun 05, 2015
ketmar
Jun 05, 2015
ketmar
Jun 05, 2015
Marc Schütz
Jun 05, 2015
ketmar
Jun 05, 2015
Marc Schütz
Jun 05, 2015
ketmar
Jun 05, 2015
Mafi
Jun 05, 2015
ketmar
Jun 05, 2015
Mafi
Jun 05, 2015
ketmar
Jun 05, 2015
Marc Schütz
Jun 05, 2015
krzaq
Jun 05, 2015
Adam D. Ruppe
Jun 06, 2015
ketmar
Jun 06, 2015
Marc Schütz
Jun 06, 2015
ketmar
Jun 06, 2015
Marc Schütz
Jun 07, 2015
ketmar
Jun 07, 2015
Marc Schütz
Jun 05, 2015
Timon Gehr
Jun 06, 2015
ketmar
Jun 07, 2015
Timon Gehr
Jun 07, 2015
Artur Skawina
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Marc Schütz
Jun 09, 2015
ketmar
Jun 09, 2015
Timon Gehr
Jun 09, 2015
ketmar
Jun 05, 2015
ketmar
Jun 05, 2015
Mafi
Jun 06, 2015
ketmar
Jun 07, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Marc Schütz
Jun 08, 2015
ketmar
Jun 08, 2015
Marc Schütz
Jun 08, 2015
Temtaime
Jun 08, 2015
Daniel Kozák
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 08, 2015
ketmar
Jun 08, 2015
Timon Gehr
Jun 06, 2015
ketmar
Jun 05, 2015
Meta
Jun 05, 2015
ketmar
Jun 05, 2015
Meta
Jun 05, 2015
Meta
Jun 05, 2015
anonymous
June 05, 2015
This is so completely bizarre that I thought I was going crazy at first, but the same behaviour is exhibited whether I'm using my own copy of std.functional or a copy cloned straight from phobos master. The following code snippet exhibits different behaviour when it is put in a standalone file than when it is in std.functional:

unittest
{
    struct Foo2
    {
        int fun(int n) pure nothrow @safe @nogc
        {
            return n;
        }
    }

    import std.traits;
    pragma(msg, ParameterTypeTuple!(typeof(Foo2.fun)));
}

If I put the following snippet in test.d and run `dmd -unittest -main test.d`, it prints `(int)`.

HOWEVER, if I append the snippet to the end of std.functional and run
`dmd -unittest -main std\functional.d`, it prints `(auto int)` instead.

Can anyone else duplicate this bug at the very least? What in the world could be causing this?
June 05, 2015
I reproduced this bug on my arch linux with DMD 2.067 and git phobos (4cea8f1e4dd839568cc9e581bc15ee84f02e7135)
June 05, 2015
here's dustmited source:

template unaryFun(alias fun, string parmName="a") {
  static if (is(typeof(fun)))
    auto unaryFun(ElementType) (auto ElementType __a) {
      mixin("alias " ~ parmName ~ " = __a ;");
      return mixin(fun);
    } else static if (needOpCallAlias) {
      unaryFun fun;
    }
}


unittest {
  cast(void)unaryFun!"a+1"(41); // silence warning
}


unittest {
  struct Foo2 {
    int fun (int n) pure nothrow @safe @nogc { return n; }
  }

  import std.traits;
  pragma(msg, ParameterTypeTuple!(typeof(Foo2.fun)));
}


# dmd -c -o- -unittest test.d to see `(auto int)`

note that after removing any attribute from `Foo2.foo` will emit correct `(int)`.
June 05, 2015
On Friday, 5 June 2015 at 02:38:39 UTC, ketmar wrote:
> here's dustmited source:

Further reduced:

void unaryFun()(auto int a) pure nothrow @safe @nogc {}
alias Identity(F) = F;
void main()
{
  unaryFun!()(41);
  static void fun(int n) pure nothrow @safe @nogc {}
  alias F = typeof(fun);
  pragma(msg, F); /* ...(int n) */
  pragma(msg, Identity!F); /* ...(auto int) */
}
June 05, 2015
On Fri, 05 Jun 2015 03:15:45 +0000, anonymous wrote:

> On Friday, 5 June 2015 at 02:38:39 UTC, ketmar wrote:
>> here's dustmited source:
> 
> Further reduced:
> 
> void unaryFun()(auto int a) pure nothrow @safe @nogc {}
> alias Identity(F) = F;
> void main()
> {
>    unaryFun!()(41);
>    static void fun(int n) pure nothrow @safe @nogc {}
>    alias F = typeof(fun);
>    pragma(msg, F); /* ...(int n) */
>    pragma(msg, Identity!F); /* ...(auto int) */
> }

`auto int a`?! it shouldn't be accepted at all!

O_O

June 05, 2015
On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote:
> `auto int a`?! it shouldn't be accepted at all!

Yeah, but it's the same with "auto ref".
June 05, 2015
On Fri, 05 Jun 2015 03:56:05 +0000, anonymous wrote:

> On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote:
>> `auto int a`?! it shouldn't be accepted at all!
> 
> Yeah, but it's the same with "auto ref".

`auto ref` has a well-defined meaning. yet `auto int` is nonsence. it's definitely a compiler bug. ;-)

June 05, 2015
On Fri, 05 Jun 2015 04:39:28 +0000, ketmar wrote:

> On Fri, 05 Jun 2015 03:56:05 +0000, anonymous wrote:
> 
>> On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote:
>>> `auto int a`?! it shouldn't be accepted at all!
>> 
>> Yeah, but it's the same with "auto ref".
> 
> `auto ref` has a well-defined meaning. yet `auto int` is nonsence. it's definitely a compiler bug. ;-)

i mean "there are at least two different things in that code, and they triggers two different compiler bugs".

June 05, 2015
On Friday, 5 June 2015 at 04:39:28 UTC, ketmar wrote:
> On Fri, 05 Jun 2015 03:56:05 +0000, anonymous wrote:
>
>> On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote:
>>> `auto int a`?! it shouldn't be accepted at all!
>> 
>> Yeah, but it's the same with "auto ref".
>
> `auto ref` has a well-defined meaning. yet `auto int` is nonsence. it's
> definitely a compiler bug. ;-)

I don't think so. `auto` is a valid storage class like `const`, `immutable` and `shared`.
June 05, 2015
On Fri, 05 Jun 2015 09:44:09 +0000, Marc Schütz wrote:

> On Friday, 5 June 2015 at 04:39:28 UTC, ketmar wrote:
>> On Fri, 05 Jun 2015 03:56:05 +0000, anonymous wrote:
>>
>>> On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote:
>>>> `auto int a`?! it shouldn't be accepted at all!
>>> 
>>> Yeah, but it's the same with "auto ref".
>>
>> `auto ref` has a well-defined meaning. yet `auto int` is nonsence. it's definitely a compiler bug. ;-)
> 
> I don't think so. `auto` is a valid storage class like `const`, `immutable` and `shared`.

`auto` is not a storage class, but a `type placeholder`. at least this is what i've been told by W or A (sorry, i can't remember the link; i think it was somewhere in NG... or in bugzilla...). there is one exception to this rule, though: `auto ref`.

« First   ‹ Prev
1 2 3 4 5 6 7