www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - incomprehensible return error bug?

reply strtr <strtr spam.com> writes:
enum { A = 0, B, C }

void func(){ return A; }

void main()
{
}

main.d(1): Error: long has no effect in expression (0)

Is this a bug?
Jan 24 2010
parent reply strtr <strtr spam.com> writes:
strtr Wrote:

 enum { A = 0, B, C }
 
 void func(){ return A; }
 
 void main()
 {
 }
 
 main.d(1): Error: long has no effect in expression (0)
 
 Is this a bug?

This error also points to the enum which is probably incorrectly used somewhere s_def(32) Error: cannot implicitly convert expression (5) of type int to S Still searching for the original bug btw :(
Jan 24 2010
parent reply strtr <strtr spam.com> writes:
strtr Wrote:

 This error also points to the enum which is probably incorrectly used somewhere
 s_def(32) Error: cannot implicitly convert expression (5) of type int to S
 
 Still searching for the original bug btw :(

Found it, also a return type mismatch problem; returning a enum member where the encapsulating struct should have been returned.
Jan 24 2010
parent reply g <g g.g> writes:
strtr Wrote:

 strtr Wrote:
 
 This error also points to the enum which is probably incorrectly used somewhere
 s_def(32) Error: cannot implicitly convert expression (5) of type int to S
 
 Still searching for the original bug btw :(

Found it, also a return type mismatch problem; returning a enum member where the encapsulating struct should have been returned.

BTW, the function says void ( no return ) and you try tu return an integer ( form a enum ) yea, is incomprehensible but is not wrong
Jan 24 2010
parent reply g <g g.g> writes:
g Wrote:

 strtr Wrote:
 
 strtr Wrote:
 
 This error also points to the enum which is probably incorrectly used somewhere
 s_def(32) Error: cannot implicitly convert expression (5) of type int to S
 
 Still searching for the original bug btw :(

Found it, also a return type mismatch problem; returning a enum member where the encapsulating struct should have been returned.


also , why in the world would you try to convert a manifest constant into a struct
Jan 24 2010
parent strtr <strtr spam.com> writes:
g Wrote:

 g Wrote:
 
 strtr Wrote:
 
 strtr Wrote:
 
 This error also points to the enum which is probably incorrectly used somewhere
 s_def(32) Error: cannot implicitly convert expression (5) of type int to S
 
 Still searching for the original bug btw :(

Found it, also a return type mismatch problem; returning a enum member where the encapsulating struct should have been returned.


also , why in the world would you try to convert a manifest constant into a struct

Oh, you misunderstand (I was probably not clear enough :) I know the bugs in my program were mine, but I think that the incomprehensibility of the error is a bug in dmd. They should point of type mismatch location, not to the enum line.
Jan 25 2010