diff options
Diffstat (limited to 'src/vim9instr.c')
-rw-r--r-- | src/vim9instr.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/vim9instr.c b/src/vim9instr.c index f5795cdf94..bd2c1b4147 100644 --- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -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: |