[Gambas-user] Issue 194 in gambas: "IIf" is buggy
Emil Lenngren
emil.lenngren at ...626...
Thu Jan 19 00:04:34 CET 2012
No :)
It should print the same as:
Print IIf(True, 1.0, 1)
Print IIf(False, 1.0, 1)
which prints
1
1
2012/1/18 Randall Morgan <rmorgan62 at ...626...>
> I think the result is correct. I would expect a result of 1,0 as 1 is equal
> to 1 but 2 is not equal to 1.
>
> On Wed, Jan 18, 2012 at 2:22 PM, <gambas at ...2524...> wrote:
>
> > Status: New
> > Owner: ----
> > Labels: Version Type-Bug Priority-Medium OpSys-Any Dist-Any Arch-Any
> > Desktop-Any GUI-Any
> >
> > New issue 194 by emil.len... at ...626...: "IIf" is buggy
> > http://code.google.com/p/gambas/issues/detail?id=194
> >
> > 1) Describe the problem.
> > IIf does not do the correct job when the true part and false part are of
> > different types.
> >
> > 2) GIVE THE FOLLOWING INFORMATIONS (if they are appropriate):
> >
> > Version: TRUNK
> > Revision: r4404
> >
> > 3) Provide a little project that reproduces the bug or the crash.
> > Dim i As Integer
> > For i = 1 To 2
> > Print Int(IIf(i = 1, 1.0, 1))
> > Next
> >
> > 5) Explain clearly how to reproduce the bug or the crash.
> > Running the code above prints out
> > 1
> > 0
> > when
> > 1
> > 1
> > is expected. This is due to that first time IIf returns a Float, but
> second
> > time an Integer. IIf should convert the return value to the one that
> > SUBR_check_good_type returns or something..., that is almost already
> > implemented ;)
> >
> > This is the current code:
> >
> > void SUBR_if(ushort code)
> > {
> > TYPE type;
> > SUBR_ENTER_PARAM(3);
> >
> > VALUE_conv_boolean(PARAM);
> >
> > switch (code & 0x1F)
> > {
> > case 0:
> >
> > type = SUBR_check_good_type(&PARAM[1], 2);
> > if (type != T_VARIANT)
> > {
> > *PC |= 1;
> > goto __TYPE;
> > }
> > else
> > {
> > *PC |= 2;
> > goto __VARIANT;
> > }
> >
> > case 1:
> > __TYPE:
> >
> > *RETURN = PARAM->_boolean.value ? PARAM[1] :
> > PARAM[2];
> >
> > break;
> >
> > case 2:
> > __VARIANT:
> >
> > if (PARAM->_boolean.value)
> > {
> > VALUE_conv_variant(&PARAM[1]);
> > *RETURN = PARAM[1];
> > }
> > else
> > {
> > VALUE_conv_variant(&PARAM[2]);
> > *RETURN = PARAM[2];
> > }
> >
> > break;
> > }
> >
> > SUBR_LEAVE();
> > }
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Keep Your Developer Skills Current with LearnDevNow!
> > The most comprehensive online learning library for Microsoft developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-d2d
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
>
>
> --
> If you ask me if it can be done. The answer is YES, it can always be done.
> The correct questions however are... What will it cost, and how long will
> it take?
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list