Skip to content

Commit 9c91998

Browse files
committed
[[ Bug 20269 ]] Error when dispatch cmd has 'with' and no params
(cherry picked from commit 074ab57)
1 parent d118bad commit 9c91998

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

docs/notes/bugfix-20269.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Throw parse error when dispatch ... with has empty params

engine/src/cmdse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ Parse_stat MCDispatchCmd::parse(MCScriptPoint& sp)
457457

458458
if (sp . skip_token(SP_REPEAT, TT_UNDEFINED, RF_WITH) == PS_NORMAL)
459459
{
460-
if (getparams(sp, &params) != PS_NORMAL)
460+
if (sp.is_eol() || getparams(sp, &params) != PS_NORMAL)
461461
{
462462
MCperror -> add(PE_DISPATCH_BADPARAMS, sp);
463463
return PS_ERROR;

engine/src/scriptpt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ class MCScriptPoint
136136

137137
return uindex_t(index);
138138
}
139+
140+
bool is_eol()
141+
{
142+
Symbol_type t_dummy;
143+
Parse_stat t_stat = next(t_dummy);
144+
backup();
145+
return t_stat == PS_EOL;
146+
}
139147

140148
Parse_stat skip_space();
141149
Parse_stat skip_eol();

0 commit comments

Comments
 (0)