##// 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 if not exp:
374 if not exp:
375 raise error.ParseError(_("missing argument"))
375 raise error.ParseError(_("missing argument"))
376 t = exp[0]
376 t = exp[0]
377 if t in curmethods:
377 return curmethods[t](exp, context)
378 return curmethods[t](exp, context)
379 raise error.ParseError(_("unknown method '%s'") % t)
380
378
381 # template evaluation
379 # template evaluation
382
380
@@ -496,6 +494,10 b' def _buildfuncargs(exp, context, curmeth'
496 def buildkeyvaluepair(exp, content):
494 def buildkeyvaluepair(exp, content):
497 raise error.ParseError(_("can't use a key-value pair in this context"))
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 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
501 # methods to interpret function arguments or inner expressions (e.g. {_(x)})
500 exprmethods = {
502 exprmethods = {
501 "integer": lambda e, c: (templateutil.runinteger, e[1]),
503 "integer": lambda e, c: (templateutil.runinteger, e[1]),
@@ -508,6 +510,7 b' exprmethods = {'
508 "%": buildmap,
510 "%": buildmap,
509 "func": buildfunc,
511 "func": buildfunc,
510 "keyvalue": buildkeyvaluepair,
512 "keyvalue": buildkeyvaluepair,
513 "list": buildlist,
511 "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b),
514 "+": lambda e, c: buildarithmetic(e, c, lambda a, b: a + b),
512 "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b),
515 "-": lambda e, c: buildarithmetic(e, c, lambda a, b: a - b),
513 "negate": buildnegate,
516 "negate": buildnegate,
@@ -188,7 +188,8 b' Call function which takes named argument'
188
188
189 $ hg debugtemplate '{" "|separate}'
189 $ hg debugtemplate '{" "|separate}'
190 $ hg debugtemplate '{("not", "an", "argument", "list")|separate}'
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 [255]
193 [255]
193
194
194 Second branch starting at nullrev:
195 Second branch starting at nullrev:
General Comments 0
You need to be logged in to leave comments. Login now