patch 9.0.0687: "export def" does not work in a nested block
Problem: "export def" does not work in a nested block.
Solution: Do not handle "export" with a separate function but in the same
command stack. (closes #11304)
diff --git a/src/vim9script.c b/src/vim9script.c
index f6c8c49..557892c 100644
--- a/src/vim9script.c
+++ b/src/vim9script.c
@@ -246,49 +246,13 @@
}
/*
- * ":export let Name: type"
- * ":export const Name: type"
- * ":export def Name(..."
- * ":export class Name ..."
+ * ":export cmd"
*/
void
-ex_export(exarg_T *eap)
+ex_export(exarg_T *eap UNUSED)
{
- int prev_did_emsg = did_emsg;
-
- if (!in_vim9script())
- {
- emsg(_(e_export_can_only_be_used_in_vim9script));
- return;
- }
-
- eap->cmd = eap->arg;
- (void)find_ex_command(eap, NULL, lookup_scriptitem, NULL);
- switch (eap->cmdidx)
- {
- case CMD_var:
- case CMD_final:
- case CMD_const:
- case CMD_def:
- case CMD_function:
- // case CMD_class:
- is_export = TRUE;
- do_cmdline(eap->cmd, eap->getline, eap->cookie,
- DOCMD_VERBOSE + DOCMD_NOWAIT);
-
- // The command will reset "is_export" when exporting an item.
- if (is_export)
- {
- if (did_emsg == prev_did_emsg)
- emsg(_(e_export_with_invalid_argument));
- is_export = FALSE;
- }
- break;
- default:
- if (did_emsg == prev_did_emsg)
- emsg(_(e_invalid_command_after_export));
- break;
- }
+ // can only get here when "export" wasn't caught in do_cmdline()
+ emsg(_(e_export_can_only_be_used_in_vim9script));
}
/*