Mercurial > vim
comparison src/vim9type.c @ 22347:712bc35842aa v8.2.1722
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Commit: https://github.com/vim/vim/commit/dbd759309b4b6abea96b18d61770e100cf4264b5
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 21 21:48:21 2020 +0200
patch 8.2.1722: Vim9: cannot assign a lambda to a variable of type function
Problem: Vim9: cannot assign a lambda to a variable of type function.
Solution: Allow for assigning a partial to a variable of type function.
(Naruhiko Nishino, closes #6996)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 21 Sep 2020 22:00:03 +0200 |
parents | a5b16c9eee9d |
children | 6a9e5c087c86 |
comparison
equal
deleted
inserted
replaced
22346:a395dbac89f7 | 22347:712bc35842aa |
---|---|
461 // When expected is "any" we accept any actual type except "void". | 461 // When expected is "any" we accept any actual type except "void". |
462 if (expected->tt_type != VAR_UNKNOWN | 462 if (expected->tt_type != VAR_UNKNOWN |
463 && !(expected->tt_type == VAR_ANY && actual->tt_type != VAR_VOID)) | 463 && !(expected->tt_type == VAR_ANY && actual->tt_type != VAR_VOID)) |
464 | 464 |
465 { | 465 { |
466 if (expected->tt_type != actual->tt_type) | 466 // tt_type should match, except that a "partial" can be assigned to a |
467 // variable with type "func". | |
468 if (!(expected->tt_type == actual->tt_type | |
469 || (expected->tt_type == VAR_FUNC | |
470 && actual->tt_type == VAR_PARTIAL))) | |
467 { | 471 { |
468 if (expected->tt_type == VAR_BOOL | 472 if (expected->tt_type == VAR_BOOL |
469 && (actual->tt_flags & TTFLAG_BOOL_OK)) | 473 && (actual->tt_flags & TTFLAG_BOOL_OK)) |
470 // Using number 0 or 1 for bool is OK. | 474 // Using number 0 or 1 for bool is OK. |
471 return OK; | 475 return OK; |