diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2018-07-27 07:31:54 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-07-27 14:31:54 +0300 |
commit | e7dcf5cf16fdab2621bacde0bfebdac88131cdb5 (patch) | |
tree | e8fc2cf8c4dea63ec05ce3a2e397c66d125079c5 /mesonbuild/mparser.py | |
parent | c7360dd426f06c67c9ceca85c0e36e02ae61c18b (diff) | |
download | meson-e7dcf5cf16fdab2621bacde0bfebdac88131cdb5.zip meson-e7dcf5cf16fdab2621bacde0bfebdac88131cdb5.tar.gz meson-e7dcf5cf16fdab2621bacde0bfebdac88131cdb5.tar.bz2 |
Warn for future keyword (#3908)
Diffstat (limited to 'mesonbuild/mparser.py')
-rw-r--r-- | mesonbuild/mparser.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 72cf143..9af6dac 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -14,6 +14,7 @@ import re import codecs +import types from .mesonlib import MesonException from . import mlog @@ -90,6 +91,7 @@ class Lexer: self.code = code self.keywords = {'true', 'false', 'if', 'else', 'elif', 'endif', 'and', 'or', 'not', 'foreach', 'endforeach'} + self.future_keywords = {'continue', 'break', 'in', 'return'} self.token_specification = [ # Need to be sorted longest to shortest. ('ignore', re.compile(r'[ \t]')), @@ -196,6 +198,9 @@ This will become a hard error in a future Meson release.""", self.getline(line_s if match_text in self.keywords: tid = match_text else: + if match_text in self.future_keywords: + mlog.warning("Identifier '{}' will become a reserved keyword in a future release. Please rename it.".format(match_text), + location=types.SimpleNamespace(subdir=subdir, lineno=lineno)) value = match_text yield Token(tid, subdir, curline_start, curline, col, bytespan, value) break |