mirror of
https://github.com/vim/vim.git
synced 2025-10-17 07:44:28 -04:00
patch 9.0.1134: comparing objects uses identity instead of equality
Problem: Comparing objects uses identity instead of equality. Solution: Compare the object values.
This commit is contained in:
@@ -254,11 +254,11 @@ check_number_or_float(vartype_T type1, vartype_T type2, char_u *op)
|
||||
*/
|
||||
int
|
||||
generate_add_instr(
|
||||
cctx_T *cctx,
|
||||
vartype_T vartype,
|
||||
type_T *type1,
|
||||
type_T *type2,
|
||||
exprtype_T expr_type)
|
||||
cctx_T *cctx,
|
||||
vartype_T vartype,
|
||||
type_T *type1,
|
||||
type_T *type2,
|
||||
exprtype_T expr_type)
|
||||
{
|
||||
isn_T *isn = generate_instr_drop(cctx,
|
||||
vartype == VAR_NUMBER ? ISN_OPNR
|
||||
@@ -416,6 +416,8 @@ get_compare_isn(
|
||||
case VAR_LIST: isntype = ISN_COMPARELIST; break;
|
||||
case VAR_DICT: isntype = ISN_COMPAREDICT; break;
|
||||
case VAR_FUNC: isntype = ISN_COMPAREFUNC; break;
|
||||
case VAR_CLASS: isntype = ISN_COMPARECLASS; break;
|
||||
case VAR_OBJECT: isntype = ISN_COMPAREOBJECT; break;
|
||||
default: isntype = ISN_COMPAREANY; break;
|
||||
}
|
||||
}
|
||||
@@ -455,6 +457,13 @@ get_compare_isn(
|
||||
exprtype == EXPR_IS ? "is" : "isnot" , vartype_name(vartype1));
|
||||
return ISN_DROP;
|
||||
}
|
||||
if (!(exprtype == EXPR_IS || exprtype == EXPR_ISNOT
|
||||
|| exprtype == EXPR_EQUAL || exprtype == EXPR_NEQUAL)
|
||||
&& (isntype == ISN_COMPAREOBJECT || isntype == ISN_COMPARECLASS))
|
||||
{
|
||||
semsg(_(e_invalid_operation_for_str), vartype_name(vartype1));
|
||||
return ISN_DROP;
|
||||
}
|
||||
if (isntype == ISN_DROP
|
||||
|| ((exprtype != EXPR_EQUAL && exprtype != EXPR_NEQUAL
|
||||
&& (vartype1 == VAR_BOOL || vartype1 == VAR_SPECIAL
|
||||
@@ -2512,12 +2521,14 @@ delete_instr(isn_T *isn)
|
||||
case ISN_COMPAREANY:
|
||||
case ISN_COMPAREBLOB:
|
||||
case ISN_COMPAREBOOL:
|
||||
case ISN_COMPARECLASS:
|
||||
case ISN_COMPAREDICT:
|
||||
case ISN_COMPAREFLOAT:
|
||||
case ISN_COMPAREFUNC:
|
||||
case ISN_COMPARELIST:
|
||||
case ISN_COMPARENR:
|
||||
case ISN_COMPARENULL:
|
||||
case ISN_COMPAREOBJECT:
|
||||
case ISN_COMPARESPECIAL:
|
||||
case ISN_COMPARESTRING:
|
||||
case ISN_CONCAT:
|
||||
|
Reference in New Issue
Block a user