##// END OF EJS Templates
templater: check invalid use of list expression properly (issue5920)...
Yuya Nishihara -
r40652:ff8b2886 default
parent child Browse files
Show More
@@ -374,9 +374,7 b' def compileexp(exp, context, curmethods)'
374 374 if not exp:
375 375 raise error.ParseError(_("missing argument"))
376 376 t = exp[0]
377 if t in curmethods:
378 return curmethods[t](exp, context)
379 raise error.ParseError(_("unknown method '%s'") % t)
377 return curmethods[t](exp, context)
380 378
381 379 # template evaluation
382 380
@@ -496,6 +494,10 b' def _buildfuncargs(exp, context, curmeth'
496 494 def buildkeyvaluepair(exp, content):
497 495 raise error.ParseError(_("can't use a key-value pair in this context"))
498 496
497 def buildlist(exp, context):
498 raise error.ParseError(_("can't use a list in this context"),
499 hint=_('check place of comma and parens'))
500
499 501 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
500 502 exprmethods = {
501 503 "integer": lambda e, c: (templateutil.runinteger, e[1]),
@@ -508,6 +510,7 b' exprmethods = {'
508 510 "%": buildmap,
509 511 "func": buildfunc,
510 512 "keyvalue": buildkeyvaluepair,
513 "list": buildlist,
511 514 "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b),
512 515 "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b),
513 516 "negate": buildnegate,
@@ -188,7 +188,8 b' Call function which takes named argument'
188 188
189 189 $ hg debugtemplate '{" "|separate}'
190 190 $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
191 hg: parse error: unknown method 'list'
191 hg: parse error: can't use a list in this context
192 (check place of comma and parens)
192 193 [255]
193 194
194 195 Second branch starting at nullrev:
General Comments 0
You need to be logged in to leave comments. Login now