Fix comparisons of derived tags (bug 6239).
This commit is contained in:
parent
7609d19e32
commit
704e9579f7
@ -647,6 +647,7 @@ char *itoh(ucell val);
|
||||
#define MATCHTAG_COERCE 0x1 // allow coercion
|
||||
#define MATCHTAG_SILENT 0x2 // silence the error(213) warning
|
||||
#define MATCHTAG_COMMUTATIVE 0x4 // order does not matter
|
||||
#define MATCHTAG_DEDUCE 0x8 // correct coercion
|
||||
|
||||
/* function prototypes in SC3.C */
|
||||
int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
|
||||
|
@ -550,7 +550,7 @@ int matchtag(int formaltag, int actualtag, int flags)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (flags & MATCHTAG_COERCE) {
|
||||
if (flags & (MATCHTAG_COERCE|MATCHTAG_DEDUCE)) {
|
||||
// See if the tag has a methodmap associated with it. If so, see if the given
|
||||
// tag is anywhere on the inheritance chain.
|
||||
methodmap_t *map = methodmap_find_by_tag(actualtag);
|
||||
@ -888,7 +888,7 @@ static void plnge2(void (*oper)(void),
|
||||
} else {
|
||||
// For the purposes of tag matching, we consider the order to be irrelevant.
|
||||
if (!checktag_string(lval1, lval2))
|
||||
matchtag(lval1->tag, lval2->tag, MATCHTAG_COMMUTATIVE);
|
||||
matchtag(lval1->tag, lval2->tag, MATCHTAG_COMMUTATIVE|MATCHTAG_DEDUCE);
|
||||
(*oper)(); /* do the (signed) operation */
|
||||
lval1->ident=iEXPRESSION;
|
||||
} /* if */
|
||||
|
18
sourcepawn/compiler/tests/ok-coerce-on-operators.sp
Normal file
18
sourcepawn/compiler/tests/ok-coerce-on-operators.sp
Normal file
@ -0,0 +1,18 @@
|
||||
enum Handle {
|
||||
INVALID_HANDLE,
|
||||
};
|
||||
|
||||
methodmap Handle {};
|
||||
methodmap ArrayList < Handle {};
|
||||
|
||||
public void MyCommand()
|
||||
{
|
||||
ArrayList myList;
|
||||
if (INVALID_HANDLE == myList)
|
||||
{
|
||||
}
|
||||
if (myList == INVALID_HANDLE)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user