Commit fd17b50c authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Warn when using too few arguments for macros in js2c.py

Change-Id: I82782f170c48dbe3f853dc04ec7e07e3968583f3
Reviewed-on: https://chromium-review.googlesource.com/724183Reviewed-by: 's avatarMathias Bynens <mathias@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48698}
parent 9fd029ef
...@@ -125,6 +125,9 @@ def ExpandMacroDefinition(lines, pos, name_pattern, macro, expander): ...@@ -125,6 +125,9 @@ def ExpandMacroDefinition(lines, pos, name_pattern, macro, expander):
end = end + 1 end = end + 1
# Remember to add the last match. # Remember to add the last match.
add_arg(lines[last_match:end-1]) add_arg(lines[last_match:end-1])
if arg_index[0] < len(macro.args) -1:
lineno = lines.count(os.linesep, 0, start) + 1
raise Error('line %s: Too few arguments for macro "%s"' % (lineno, name_pattern.pattern))
result = macro.expand(mapping) result = macro.expand(mapping)
# Replace the occurrence of the macro with the expansion # Replace the occurrence of the macro with the expansion
lines = lines[:start] + result + lines[end:] lines = lines[:start] + result + lines[end:]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment