INIT(= N_("E1252: String, List or Blob required for argument %d"));
EXTERN char e_string_expected_for_argument_nr[]
INIT(= N_("E1253: String expected for argument %d"));
+EXTERN char e_cannot_use_script_variable_in_for_loop[]
+ INIT(= N_("E1254: Cannot use script variable in for loop"));
def Test_for_loop_script_var()
# cannot use s:var in a :def function
- CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E461:')
+ CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:')
# can use s:var in Vim9 script, with or without s:
var lines =<< trim END
lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
}
- // Script var is not supported.
if (get_var_dest(name, &dest, CMD_for, &opt_flags,
&vimvaridx, &type, cctx) == FAIL)
goto failed;
}
else
{
- if (!valid_varname(arg, (int)varlen, FALSE))
- goto failed;
- if (lookup_local(arg, varlen, NULL, cctx) == OK)
+ // Script var is not supported.
+ if (STRNCMP(name, "s:", 2) == 0)
{
- semsg(_(e_variable_already_declared), arg);
+ emsg(_(e_cannot_use_script_variable_in_for_loop));
goto failed;
}
- if (STRNCMP(name, "s:", 2) == 0)
+ if (!valid_varname(arg, (int)varlen, FALSE))
+ goto failed;
+ if (lookup_local(arg, varlen, NULL, cctx) == OK)
{
- semsg(_(e_cannot_declare_script_variable_in_function), name);
+ semsg(_(e_variable_already_declared), arg);
goto failed;
}