Mercurial > vim
comparison src/testdir/test_vim9_disassemble.vim @ 23428:5807e3958e38 v8.2.2257
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Commit: https://github.com/vim/vim/commit/2949cfdbe4335b9abcfeda1be4dfc52090ee1df6
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 31 21:28:47 2020 +0100
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Problem: Vim9: using -> for lambda is ambiguous.
Solution: Stop supporting ->, must use =>.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 31 Dec 2020 21:30:03 +0100 |
parents | 9bd3873b13e2 |
children | 4c6ebf531284 |
comparison
equal
deleted
inserted
replaced
23427:8f2dcc0cfcf6 | 23428:5807e3958e38 |
---|---|
894 '\d RETURN', | 894 '\d RETURN', |
895 instr) | 895 instr) |
896 enddef | 896 enddef |
897 | 897 |
898 def WithLambda(): string | 898 def WithLambda(): string |
899 var F = {a -> "X" .. a .. "X"} | 899 var F = (a) => "X" .. a .. "X" |
900 return F("x") | 900 return F("x") |
901 enddef | 901 enddef |
902 | 902 |
903 def Test_disassemble_lambda() | 903 def Test_disassemble_lambda() |
904 assert_equal("XxX", WithLambda()) | 904 assert_equal("XxX", WithLambda()) |
905 var instr = execute('disassemble WithLambda') | 905 var instr = execute('disassemble WithLambda') |
906 assert_match('WithLambda\_s*' .. | 906 assert_match('WithLambda\_s*' .. |
907 'var F = {a -> "X" .. a .. "X"}\_s*' .. | 907 'var F = (a) => "X" .. a .. "X"\_s*' .. |
908 '\d FUNCREF <lambda>\d\+\_s*' .. | 908 '\d FUNCREF <lambda>\d\+\_s*' .. |
909 '\d STORE $0\_s*' .. | 909 '\d STORE $0\_s*' .. |
910 'return F("x")\_s*' .. | 910 'return F("x")\_s*' .. |
911 '\d PUSHS "x"\_s*' .. | 911 '\d PUSHS "x"\_s*' .. |
912 '\d LOAD $0\_s*' .. | 912 '\d LOAD $0\_s*' .. |
927 '\d RETURN', | 927 '\d RETURN', |
928 instr) | 928 instr) |
929 enddef | 929 enddef |
930 | 930 |
931 def LambdaWithType(): number | 931 def LambdaWithType(): number |
932 var Ref = {a: number -> a + 10} | 932 var Ref = (a: number) => a + 10 |
933 return Ref(g:value) | 933 return Ref(g:value) |
934 enddef | 934 enddef |
935 | 935 |
936 def Test_disassemble_lambda_with_type() | 936 def Test_disassemble_lambda_with_type() |
937 g:value = 5 | 937 g:value = 5 |
938 assert_equal(15, LambdaWithType()) | 938 assert_equal(15, LambdaWithType()) |
939 var instr = execute('disassemble LambdaWithType') | 939 var instr = execute('disassemble LambdaWithType') |
940 assert_match('LambdaWithType\_s*' .. | 940 assert_match('LambdaWithType\_s*' .. |
941 'var Ref = {a: number -> a + 10}\_s*' .. | 941 'var Ref = (a: number) => a + 10\_s*' .. |
942 '\d FUNCREF <lambda>\d\+\_s*' .. | 942 '\d FUNCREF <lambda>\d\+\_s*' .. |
943 '\d STORE $0\_s*' .. | 943 '\d STORE $0\_s*' .. |
944 'return Ref(g:value)\_s*' .. | 944 'return Ref(g:value)\_s*' .. |
945 '\d LOADG g:value\_s*' .. | 945 '\d LOADG g:value\_s*' .. |
946 '\d LOAD $0\_s*' .. | 946 '\d LOAD $0\_s*' .. |
1539 ['{a: 1} == aDict', 'COMPAREDICT =='], | 1539 ['{a: 1} == aDict', 'COMPAREDICT =='], |
1540 ['{a: 1} != aDict', 'COMPAREDICT !='], | 1540 ['{a: 1} != aDict', 'COMPAREDICT !='], |
1541 ['{a: 1} is aDict', 'COMPAREDICT is'], | 1541 ['{a: 1} is aDict', 'COMPAREDICT is'], |
1542 ['{a: 1} isnot aDict', 'COMPAREDICT isnot'], | 1542 ['{a: 1} isnot aDict', 'COMPAREDICT isnot'], |
1543 | 1543 |
1544 ['{-> 33} == {-> 44}', 'COMPAREFUNC =='], | 1544 ['(() => 33) == (() => 44)', 'COMPAREFUNC =='], |
1545 ['{-> 33} != {-> 44}', 'COMPAREFUNC !='], | 1545 ['(() => 33) != (() => 44)', 'COMPAREFUNC !='], |
1546 ['{-> 33} is {-> 44}', 'COMPAREFUNC is'], | 1546 ['(() => 33) is (() => 44)', 'COMPAREFUNC is'], |
1547 ['{-> 33} isnot {-> 44}', 'COMPAREFUNC isnot'], | 1547 ['(() => 33) isnot (() => 44)', 'COMPAREFUNC isnot'], |
1548 | 1548 |
1549 ['77 == g:xx', 'COMPAREANY =='], | 1549 ['77 == g:xx', 'COMPAREANY =='], |
1550 ['77 != g:xx', 'COMPAREANY !='], | 1550 ['77 != g:xx', 'COMPAREANY !='], |
1551 ['77 > g:xx', 'COMPAREANY >'], | 1551 ['77 > g:xx', 'COMPAREANY >'], |
1552 ['77 < g:xx', 'COMPAREANY <'], | 1552 ['77 < g:xx', 'COMPAREANY <'], |