Mercurial > vim
comparison src/vim9instr.c @ 28103:1615d305c71d v8.2.4576
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Commit: https://github.com/vim/vim/commit/056678184f679c2989b73bd48eda112f3c79a62f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 15 20:21:33 2022 +0000
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Problem: Vim9: error for comparing with null can be annoying.
Solution: Allow comparing anything with null. (closes https://github.com/vim/vim/issues/9948)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 15 Mar 2022 21:30:03 +0100 |
parents | 3bc0a639dfb0 |
children | 088d8dc22045 |
comparison
equal
deleted
inserted
replaced
28102:9aa6dfbd4698 | 28103:1615d305c71d |
---|---|
395 { | 395 { |
396 semsg(_(e_cannot_compare_str_with_str), | 396 semsg(_(e_cannot_compare_str_with_str), |
397 vartype_name(vartype1), vartype_name(vartype2)); | 397 vartype_name(vartype1), vartype_name(vartype2)); |
398 return ISN_DROP; | 398 return ISN_DROP; |
399 } | 399 } |
400 switch (vartype1 == VAR_SPECIAL ? vartype2 : vartype1) | 400 // although comparing null with number, float or bool is not useful, we |
401 { | 401 // allow it |
402 case VAR_BLOB: break; | |
403 case VAR_CHANNEL: break; | |
404 case VAR_DICT: break; | |
405 case VAR_FUNC: break; | |
406 case VAR_JOB: break; | |
407 case VAR_LIST: break; | |
408 case VAR_PARTIAL: break; | |
409 case VAR_STRING: break; | |
410 default: semsg(_(e_cannot_compare_str_with_str), | |
411 vartype_name(vartype1), vartype_name(vartype2)); | |
412 return ISN_DROP; | |
413 } | |
414 isntype = ISN_COMPARENULL; | 402 isntype = ISN_COMPARENULL; |
415 } | 403 } |
416 | 404 |
417 if ((exprtype == EXPR_IS || exprtype == EXPR_ISNOT) | 405 if ((exprtype == EXPR_IS || exprtype == EXPR_ISNOT) |
418 && (isntype == ISN_COMPAREBOOL | 406 && (isntype == ISN_COMPAREBOOL |