From d169619f69189a4cbda8eb806abdc865906e8e58 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 15 Jun 2022 21:31:16 +0200 Subject: [PATCH] Warn if token type is a table when not needed --- data/core/tokenizer.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/core/tokenizer.lua b/data/core/tokenizer.lua index b00d30e5..fe826aae 100644 --- a/data/core/tokenizer.lua +++ b/data/core/tokenizer.lua @@ -272,7 +272,11 @@ function tokenizer.tokenize(incoming_syntax, text, state) if find_results[1] then local type_is_table = type(p.type) == "table" local n_types = type_is_table and #p.type or 1 - if #find_results - 1 > n_types then + if #find_results == 2 and type_is_table then + report_bad_pattern(core.warn, current_syntax, n, + "Token type is a table, but a string was expected.") + p.type = p.type[1] + elseif #find_results - 1 > n_types then report_bad_pattern(core.error, current_syntax, n, "Not enough token types: got %d needed %d.", n_types, #find_results - 1) elseif #find_results - 1 < n_types then