comparison src/testdir/test_vim9_script.vim @ 20401:918b9a05cf35 v8.2.0755

patch 8.2.0755: Vim9: No error when variable initializer is not a constant Commit: https://github.com/vim/vim/commit/227a69de1e0f9457a9fc9e098d999304faff55f8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 15 18:17:28 2020 +0200 patch 8.2.0755: Vim9: No error when variable initializer is not a constant Problem: Vim9: No error when variable initializer is not a constant. Solution: Return FAIL when trying to get a variable value. Do not execute a script when an error is deteted in the first or second phase.
author Bram Moolenaar <Bram@vim.org>
date Fri, 15 May 2020 18:30:04 +0200
parents d1a54d2bd145
children d54dfb5f12db
comparison
equal deleted inserted replaced
20400:9a53e38d4abb 20401:918b9a05cf35
492 vim9script 492 vim9script
493 let name: string = 'bob' 493 let name: string = 'bob'
494 def Concat(arg: string): string 494 def Concat(arg: string): string
495 return name .. arg 495 return name .. arg
496 enddef 496 enddef
497 let g:result: string = Concat('bie') 497 g:result = Concat('bie')
498 let g:localname = name 498 g:localname = name
499 499
500 export const CONST = 1234 500 export const CONST = 1234
501 export let exported = 9876 501 export let exported = 9876
502 export let exp_name = 'John' 502 export let exp_name = 'John'
503 export def Exported(): string 503 export def Exported(): string
1745 func GetValue() 1745 func GetValue()
1746 return 'this' 1746 return 'this'
1747 endfunc 1747 endfunc
1748 let val = GetValue() 1748 let val = GetValue()
1749 END 1749 END
1750 writefile(lines, 'Xfinished') 1750 CheckScriptFailure(lines, 'E1091:')
1751 assert_fails('source Xfinished', 'E1091:') 1751
1752 1752 lines =<< trim END
1753 delete('Xfinished') 1753 vim9script
1754 let var = g:unkown
1755 END
1756 CheckScriptFailure(lines, 'E1091:')
1757
1758 " TODO: eventually this would work
1759 lines =<< trim END
1760 vim9script
1761 let var = has('eval')
1762 END
1763 CheckScriptFailure(lines, 'E1091:')
1764
1765 " TODO: eventually this would work
1766 lines =<< trim END
1767 vim9script
1768 let var = len('string')
1769 END
1770 CheckScriptFailure(lines, 'E1091:')
1771
1772 lines =<< trim END
1773 vim9script
1774 let nr: number = 123
1775 let var = nr
1776 END
1777 CheckScriptFailure(lines, 'E1091:')
1754 enddef 1778 enddef
1755 1779
1756 def Test_forward_declaration() 1780 def Test_forward_declaration()
1757 let lines =<< trim END 1781 let lines =<< trim END
1758 vim9script 1782 vim9script