Skip to content

Commit 1b5f7a6

Browse files
committed
patch 8.2.3868: Vim9: function test fails
Problem: Vim9: function test fails. Solution: Add missing changes. Add test for earlier patch.
1 parent d92813a commit 1b5f7a6

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

src/testdir/test_vim9_disassemble.vim

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,27 +2328,43 @@ def s:ElseifConstant()
23282328
elseif false
23292329
echo "false"
23302330
endif
2331+
if 0
2332+
echo "yes"
2333+
elseif 0
2334+
echo "no"
2335+
endif
23312336
enddef
23322337

23332338
def Test_debug_elseif_constant()
2334-
var res = execute('disass s:ElseifConstant')
2339+
var res = execute('disass debug s:ElseifConstant')
23352340
assert_match('<SNR>\d*_ElseifConstant\_s*' ..
23362341
'if g:value\_s*' ..
2337-
'0 LOADG g:value\_s*' ..
2338-
'1 COND2BOOL\_s*' ..
2339-
'2 JUMP_IF_FALSE -> 6\_s*' ..
2342+
'0 DEBUG line 1-1 varcount 0\_s*' ..
2343+
'1 LOADG g:value\_s*' ..
2344+
'2 COND2BOOL\_s*' ..
2345+
'3 JUMP_IF_FALSE -> 8\_s*' ..
23402346
'echo "one"\_s*' ..
2341-
'3 PUSHS "one"\_s*' ..
2342-
'4 ECHO 1\_s*' ..
2347+
'4 DEBUG line 2-2 varcount 0\_s*' ..
2348+
'5 PUSHS "one"\_s*' ..
2349+
'6 ECHO 1\_s*' ..
23432350
'elseif true\_s*' ..
2344-
'5 JUMP -> 8\_s*' ..
2351+
'7 JUMP -> 12\_s*' ..
2352+
'8 DEBUG line 3-3 varcount 0\_s*' ..
23452353
'echo "true"\_s*' ..
2346-
'6 PUSHS "true"\_s*' ..
2347-
'7 ECHO 1\_s*' ..
2354+
'9 DEBUG line 4-4 varcount 0\_s*' ..
2355+
'10 PUSHS "true"\_s*' ..
2356+
'11 ECHO 1\_s*' ..
23482357
'elseif false\_s*' ..
23492358
'echo "false"\_s*' ..
23502359
'endif\_s*' ..
2351-
'\d RETURN void*',
2360+
'if 0\_s*' ..
2361+
'12 DEBUG line 8-8 varcount 0\_s*' ..
2362+
'echo "yes"\_s*' ..
2363+
'elseif 0\_s*' ..
2364+
'13 DEBUG line 11-10 varcount 0\_s*' ..
2365+
'echo "no"\_s*' ..
2366+
'endif\_s*' ..
2367+
'14 RETURN void*',
23522368
res)
23532369
enddef
23542370

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ static char *(features[]) =
749749

750750
static int included_patches[] =
751751
{ /* Add new patch number below this line */
752+
/**/
753+
3868,
752754
/**/
753755
3867,
754756
/**/

src/vim9type.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,9 @@ check_type_maybe(
567567
{
568568
// tt_type should match, except that a "partial" can be assigned to a
569569
// variable with type "func".
570+
// And "unknown" (using global variable) needs a runtime type check.
570571
if (!(expected->tt_type == actual->tt_type
572+
|| actual->tt_type == VAR_UNKNOWN
571573
|| (expected->tt_type == VAR_FUNC
572574
&& actual->tt_type == VAR_PARTIAL)))
573575
{
@@ -582,7 +584,7 @@ check_type_maybe(
582584
if (expected->tt_type == VAR_DICT || expected->tt_type == VAR_LIST)
583585
{
584586
// "unknown" is used for an empty list or dict
585-
if (actual->tt_member != &t_unknown)
587+
if (actual->tt_member != NULL && actual->tt_member != &t_unknown)
586588
ret = check_type(expected->tt_member, actual->tt_member,
587589
FALSE, where);
588590
}
@@ -592,7 +594,8 @@ check_type_maybe(
592594
// nothing, thus there is no point in checking.
593595
if (expected->tt_member != &t_unknown)
594596
{
595-
if (actual->tt_member != &t_unknown)
597+
if (actual->tt_member != NULL
598+
&& actual->tt_member != &t_unknown)
596599
ret = check_type(expected->tt_member, actual->tt_member,
597600
FALSE, where);
598601
else

0 commit comments

Comments
 (0)