Thread overview
Is this a bug? `static if` fails silently.
Nov 04, 2014
Meta
Nov 04, 2014
deadalnix
Nov 04, 2014
Meta
Nov 04, 2014
John Colvin
Nov 04, 2014
John Colvin
Nov 04, 2014
Tofu Ninja
Nov 04, 2014
Meta
November 04, 2014
struct Test(T)
{
	static if (is(typeof(T) == int))
	{
		pragma(msg, "test");
		
		this(T t)
		{
			this.t = t;
		}
	}
}

void main()
{
        //Nothing is printed
	Test!int t;
}

Didn't this code used to failed at the point of `typeof(T)`? Has this changed since previous releases?
November 04, 2014
On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:
> struct Test(T)
> {
> 	static if (is(typeof(T) == int))
> 	{
> 		pragma(msg, "test");
> 		
> 		this(T t)
> 		{
> 			this.t = t;
> 		}
> 	}
> }
>
> void main()
> {
>         //Nothing is printed
> 	Test!int t;
> }
>
> Didn't this code used to failed at the point of `typeof(T)`? Has this changed since previous releases?

It is not static if, it is is. Is is defined as false for invalid types.
November 04, 2014
On Tuesday, 4 November 2014 at 09:07:10 UTC, deadalnix wrote:
> It is not static if, it is is. Is is defined as false for invalid types.

Ah, right. That's annoyingly hard to spot, but it is not a bug I suppose.
November 04, 2014
On Tuesday, 4 November 2014 at 09:07:10 UTC, deadalnix wrote:
> On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:
>> struct Test(T)
>> {
>> 	static if (is(typeof(T) == int))
>> 	{
>> 		pragma(msg, "test");
>> 		
>> 		this(T t)
>> 		{
>> 			this.t = t;
>> 		}
>> 	}
>> }
>>
>> void main()
>> {
>>        //Nothing is printed
>> 	Test!int t;
>> }
>>
>> Didn't this code used to failed at the point of `typeof(T)`? Has this changed since previous releases?
>
> It is not static if, it is is. Is is defined as false for invalid types.

a std.traits.TypeOf that errors out on non-types would be nice.
November 04, 2014
On Tuesday, 4 November 2014 at 09:54:44 UTC, John Colvin wrote:
> On Tuesday, 4 November 2014 at 09:07:10 UTC, deadalnix wrote:
>> On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:
>>> struct Test(T)
>>> {
>>> 	static if (is(typeof(T) == int))
>>> 	{
>>> 		pragma(msg, "test");
>>> 		
>>> 		this(T t)
>>> 		{
>>> 			this.t = t;
>>> 		}
>>> 	}
>>> }
>>>
>>> void main()
>>> {
>>>       //Nothing is printed
>>> 	Test!int t;
>>> }
>>>
>>> Didn't this code used to failed at the point of `typeof(T)`? Has this changed since previous releases?
>>
>> It is not static if, it is is. Is is defined as false for invalid types.
>
> a std.traits.TypeOf that errors out on non-types would be nice.

woops, ignore me.
November 04, 2014
On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:

> typeof(T)

What is the type of a type?
November 04, 2014
On Tuesday, 4 November 2014 at 21:20:59 UTC, Tofu Ninja wrote:
> On Tuesday, 4 November 2014 at 09:00:12 UTC, Meta wrote:
>
>> typeof(T)
>
> What is the type of a type?

A kind, of course. =)