From 1507cf98dc95ba03b16ecb42621e50f34abb942e Mon Sep 17 00:00:00 2001 From: ydah Date: Mon, 9 Dec 2024 19:42:15 +0900 Subject: [PATCH] Fix a warning for Ruby::UnannotatedEmptyCollection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` lib/lrama/grammar.rb:385:15: [warning] Empty array doesn't have type annotation │ Diagnostic ID: Ruby::UnannotatedEmptyCollection │ └ errors = [] ~~ ``` --- lib/lrama/grammar.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lrama/grammar.rb b/lib/lrama/grammar.rb index 3724f828..001f5861 100644 --- a/lib/lrama/grammar.rb +++ b/lib/lrama/grammar.rb @@ -382,12 +382,10 @@ def fill_sym_to_rules end def validate_rule_lhs_is_nterm! - errors = [] - - rules.each do |rule| + errors = rules.each_with_object(Array.new) do |rule, list| next if rule.lhs.nterm? - errors << "[BUG] LHS of #{rule.display_name} (line: #{rule.lineno}) is term. It should be nterm." + list << "[BUG] LHS of #{rule.display_name} (line: #{rule.lineno}) is term. It should be nterm." end return if errors.empty?