From e7dcf5cf16fdab2621bacde0bfebdac88131cdb5 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 27 Jul 2018 07:31:54 -0400 Subject: [PATCH] Warn for future keyword (#3908) --- mesonbuild/mparser.py | 5 +++++ .../170 custom target template substitution/meson.build | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 72cf1431e..9af6daca1 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 diff --git a/test cases/common/170 custom target template substitution/meson.build b/test cases/common/170 custom target template substitution/meson.build index 3f6a15951..737408ebf 100644 --- a/test cases/common/170 custom target template substitution/meson.build +++ b/test cases/common/170 custom target template substitution/meson.build @@ -4,12 +4,12 @@ check = find_program('checkcopy.py') config = configuration_data() -in = configure_file(configuration : config, output : 'x@IN') +config_file = configure_file(configuration : config, output : 'x@IN') # Check that substitution does not find @FOO@ and then misses @INPUT0@. # Check the resulting x@INPUT1@ is not replaced. foo = custom_target('runcheck', - input : [in, 'foo.c.in'], + input : [config_file, 'foo.c.in'], output : 'foo.c', command : [check, '-D@FOO@INPUT0@PUT1@', '@INPUT1@', '@OUTPUT@'] )