From ed52a12f6b611af2e87dc559a0f9f65ca5c81f7d Mon Sep 17 00:00:00 2001 From: mzuenni Date: Wed, 10 Apr 2024 23:40:43 +0200 Subject: [PATCH] improve error message --- bin/problem.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/problem.py b/bin/problem.py index 544a2e23f..4231adc87 100644 --- a/bin/problem.py +++ b/bin/problem.py @@ -176,11 +176,17 @@ def _read_settings(self): fatal(f'could not parse constants in {self.name}/problem.yaml') raw_constants = self.settings.constants self.settings.constants = { - k: v for k, v in raw_constants.items() if isinstance(v, (str, int, float)) + k: v + for k, v in raw_constants.items() + if isinstance(v, (str, int, float)) + and config.SUBSTITUTE_NAME_REGEX.fullmatch(k) is not None } for k in raw_constants: if k not in self.settings.constants: - error(f'invalid value for constant {k} in {self.name}/problem.yaml (ignored)') + if config.SUBSTITUTE_NAME_REGEX.fullmatch(key) is None: + error(f'invalid name "{k}" for constant in {self.name}/problem.yaml (ignored)') + else: + error(f'invalid value for constant {k} in {self.name}/problem.yaml (ignored)') # reserved constants (and backwards compatibility) known_constants = {