-*eval.txt* For Vim version 9.1. Last change: 2025 Dec 13
+*eval.txt* For Vim version 9.1. Last change: 2025 Dec 17
VIM REFERENCE MANUAL by Bram Moolenaar
Dictionary and arguments, use |get()| to get the function name: >
if get(Part1, 'name') == get(Part2, 'name')
" Part1 and Part2 refer to the same function
-< *E1037*
+<
+ *E1437*
+An |Object| can only be compared with another |Object|, using only the
+"equal", "not equal", "is" and "isnot" operators |expr4|. An |Enum| is also a
+type of |Object|, and the same rules apply.
+
+ *E1037*
Using "is" or "isnot" with a |List|, |Tuple|, |Dictionary| or |Blob| checks
whether the expressions are referring to the same |List|, |Tuple|,
|Dictionary| or |Blob| instance. A copy of a |List| or |Tuple| is different
E1434 vim9.txt /*E1434*
E1435 vim9class.txt /*E1435*
E1436 vim9class.txt /*E1436*
+E1437 eval.txt /*E1437*
E144 various.txt /*E144*
E145 starting.txt /*E145*
E146 change.txt /*E146*
INIT(= N_("E1435: Enum can only be used in a script"));
EXTERN char e_interface_can_only_be_used_in_script[]
INIT(= N_("E1436: Interface can only be used in a script"));
+EXTERN char e_can_only_compare_object_with_object[]
+ INIT(= N_("E1437: Can only compare Object with Object"));
#endif
-// E1437 - E1499 unused (reserved for Vim9 class support)
+// E1438 - E1499 unused (reserved for Vim9 class support)
EXTERN char e_cannot_mix_positional_and_non_positional_str[]
INIT(= N_("E1500: Cannot mix positional and non-positional arguments: %s"));
EXTERN char e_fmt_arg_nr_unused_str[]
msgstr ""
"Project-Id-Version: Vim\n"
"Report-Msgid-Bugs-To: vim-dev@vim.org\n"
-"POT-Creation-Date: 2025-12-13 17:59+0100\n"
+"POT-Creation-Date: 2025-12-17 21:42+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "Sponsor Vim development!"
msgstr ""
-msgid "Become a registered Vim user!"
-msgstr ""
-
msgid "type :help sponsor<Enter> for information "
msgstr ""
-msgid "type :help register<Enter> for information "
-msgstr ""
-
-msgid "menu Help->Sponsor/Register for information "
+msgid "menu Help->Sponsor for information "
msgstr ""
msgid "global"
msgid "E1436: Interface can only be used in a script"
msgstr ""
+msgid "E1437: Can only compare Object with Object"
+msgstr ""
+
#, c-format
msgid "E1500: Cannot mix positional and non-positional arguments: %s"
msgstr ""
x['a'] = {}
END
v9.CheckSourceDefAndScriptFailure(lines, ['E1012: Type mismatch; expected object<any> but got dict<any>', 'E1012: Type mismatch; expected object<any> but got dict<any>'])
+
+ # Error if comparing object with non object when using COMPAREANY instruction
+ lines =<< trim END
+ vim9script
+
+ enum DirectiveType
+ Unknown,
+ Set
+ endenum
+
+ type PatternSteps = list<any>
+ type Directive = tuple<DirectiveType, PatternSteps>
+
+ def Test(): void
+ var directive: Directive = (DirectiveType.Unknown, ["eq", 1, "hello"])
+
+ if directive[0] == "test"
+ endif
+ enddef
+
+ Test()
+ END
+ v9.CheckSourceFailure(lines, 'E1437: Can only compare Object with Object', 3)
enddef
" Test for object<{class}> type
*res = obj1 == obj2 ? res_match : !res_match;
return OK;
}
+ else if (tv1->v_type != tv2->v_type)
+ {
+ emsg(_(e_can_only_compare_object_with_object));
+ return FAIL;
+ }
*res = object_equal(obj1, obj2, ic) ? res_match : !res_match;
return OK;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1992,
/**/
1991,
/**/