[Issue 10413] .init incorrectly accepts any expression

2019-11-02 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10413

Nicholas Wilson  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||iamthewilsona...@hotmail.co
   ||m
 Resolution|--- |INVALID

--- Comment #5 from Nicholas Wilson  ---
int foo() { return 1; }

static assert(foo.init == 0);

is a case of optional parentheses, as

char foo() { return 1; }

static assert(foo.init == 255);

passes, but 

int foo(int) { return 1; }

static assert(foo.init == 0);

fails with 

onlineapp.d(3): Error: function onlineapp.foo(int) is not callable using
argument types ()
onlineapp.d(3):missing argument for parameter #1: int
onlineapp.d(3):while evaluating: static assert((__error).init == 0)

closing as invalid

--


[Issue 10413] .init incorrectly accepts any expression

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10413

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|D1  D2 |D2

--


[Issue 10413] .init incorrectly accepts any expression

2014-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10413

Andrej Mitrovic andrej.mitrov...@gmail.com changed:

   What|Removed |Added

 CC||andrej.mitrov...@gmail.com

--- Comment #4 from Andrej Mitrovic andrej.mitrov...@gmail.com ---
According to Walter it's ok if a UDT defines its own .init, which would make
value.init valid: https://issues.dlang.org/show_bug.cgi?id=7066

I don't agree with him though, especially since the whole argument against
allowing user-defined default ctors is the compile-time known .init property.

--


[Issue 10413] .init incorrectly accepts any expression

2014-04-08 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=10413



--- Comment #3 from monarchdo...@gmail.com 2014-04-08 08:12:41 PDT ---
(In reply to comment #2)
 instance of having
 to pulling out the typeof.

I mean instead of having to pull out the typeof.

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


[Issue 10413] .init incorrectly accepts any expression

2014-04-08 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=10413


monarchdo...@gmail.com changed:

   What|Removed |Added

 CC||monarchdo...@gmail.com


--- Comment #2 from monarchdo...@gmail.com 2014-04-08 08:10:53 PDT ---
(In reply to comment #1)
 With constructions like:
 template Foo(T...)

  T[0].init
 is OK if T[0] is a type, but if it is a value, it won't compile.

If the template code doesn't make sense, then it doesn't compile. Seems fine to
me.

 It is in fact pretty bizarre that 2.init == 0, so this should probably be
 changed.

.init is a static property, and as such, can be called on either type or
instance, just the same way you can write assert(1.max == 0x7FF). As a
matter of fact, I'm pretty sure I've seen this used before, instance of having
to pulling out the typeof.

I'm not sure changing this would be correct.

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


[Issue 10413] .init incorrectly accepts any expression

2013-06-26 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10413



--- Comment #1 from Don clugd...@yahoo.com.au 2013-06-25 23:57:58 PDT ---
Pull request:
https://github.com/D-Programming-Language/dmd/pull/2240

This fails Phobos unit tests in multiple places, for example:

std/traits.d(3654): Error: static assert  (is(void == double)) is false

With constructions like:
template Foo(T...)

 T[0].init
is OK if T[0] is a type, but if it is a value, it won't compile.
It is in fact pretty bizarre that 2.init == 0, so this should probably be
changed.

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