Mercurial > vim
comparison src/vim9compile.c @ 24404:a2a7d2d6e724 v8.2.2742
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Commit: https://github.com/vim/vim/commit/701cc6ca9e940665a9424541f989bb38c853a498
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 10 13:33:48 2021 +0200
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Problem: Vim9: when compiling a function fails it is cleared.
Solution: Keep the function lines, prevent execution with a different
status. (closes #8093)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Apr 2021 13:45:05 +0200 |
parents | 009a540f16a6 |
children | a26f0fa12845 |
comparison
equal
deleted
inserted
replaced
24403:1df57caa70c0 | 24404:a2a7d2d6e724 |
---|---|
1789 int | 1789 int |
1790 func_needs_compiling(ufunc_T *ufunc, int profile UNUSED) | 1790 func_needs_compiling(ufunc_T *ufunc, int profile UNUSED) |
1791 { | 1791 { |
1792 switch (ufunc->uf_def_status) | 1792 switch (ufunc->uf_def_status) |
1793 { | 1793 { |
1794 case UF_NOT_COMPILED: break; | 1794 case UF_TO_BE_COMPILED: |
1795 case UF_TO_BE_COMPILED: return TRUE; | 1795 return TRUE; |
1796 | |
1796 case UF_COMPILED: | 1797 case UF_COMPILED: |
1797 { | 1798 { |
1798 #ifdef FEAT_PROFILE | 1799 #ifdef FEAT_PROFILE |
1799 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) | 1800 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) |
1800 + ufunc->uf_dfunc_idx; | 1801 + ufunc->uf_dfunc_idx; |
1803 : dfunc->df_instr == NULL; | 1804 : dfunc->df_instr == NULL; |
1804 #else | 1805 #else |
1805 break; | 1806 break; |
1806 #endif | 1807 #endif |
1807 } | 1808 } |
1808 case UF_COMPILING: break; | 1809 |
1810 case UF_NOT_COMPILED: | |
1811 case UF_COMPILE_ERROR: | |
1812 case UF_COMPILING: | |
1813 break; | |
1809 } | 1814 } |
1810 return FALSE; | 1815 return FALSE; |
1811 } | 1816 } |
1812 | 1817 |
1813 /* | 1818 /* |
1832 { | 1837 { |
1833 semsg(_(e_toofewarg), printable_func_name(ufunc)); | 1838 semsg(_(e_toofewarg), printable_func_name(ufunc)); |
1834 return FAIL; | 1839 return FAIL; |
1835 } | 1840 } |
1836 | 1841 |
1837 if (ufunc->uf_def_status != UF_NOT_COMPILED) | 1842 if (ufunc->uf_def_status != UF_NOT_COMPILED |
1843 && ufunc->uf_def_status != UF_COMPILE_ERROR) | |
1838 { | 1844 { |
1839 int i; | 1845 int i; |
1840 | 1846 |
1841 for (i = 0; i < argcount; ++i) | 1847 for (i = 0; i < argcount; ++i) |
1842 { | 1848 { |
9005 && ufunc->uf_dfunc_idx == def_functions.ga_len - 1) | 9011 && ufunc->uf_dfunc_idx == def_functions.ga_len - 1) |
9006 { | 9012 { |
9007 --def_functions.ga_len; | 9013 --def_functions.ga_len; |
9008 ufunc->uf_dfunc_idx = 0; | 9014 ufunc->uf_dfunc_idx = 0; |
9009 } | 9015 } |
9010 ufunc->uf_def_status = UF_NOT_COMPILED; | 9016 ufunc->uf_def_status = UF_COMPILE_ERROR; |
9011 | 9017 |
9012 while (cctx.ctx_scope != NULL) | 9018 while (cctx.ctx_scope != NULL) |
9013 drop_scope(&cctx); | 9019 drop_scope(&cctx); |
9014 | |
9015 // Don't execute this function body. | |
9016 ga_clear_strings(&ufunc->uf_lines); | |
9017 | 9020 |
9018 if (errormsg != NULL) | 9021 if (errormsg != NULL) |
9019 emsg(errormsg); | 9022 emsg(errormsg); |
9020 else if (did_emsg == did_emsg_before) | 9023 else if (did_emsg == did_emsg_before) |
9021 emsg(_(e_compiling_def_function_failed)); | 9024 emsg(_(e_compiling_def_function_failed)); |