From a904279b1a83eda12aa66be0da8cdae21ce2be8d Mon Sep 17 00:00:00 2001 From: ydah Date: Mon, 9 Dec 2024 19:40: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/lexer/token/user_code.rb:19:23: [warning] Empty array doesn't have type annotation │ Diagnostic ID: Ruby::UnannotatedEmptyCollection │ └ references = [] ~~ ``` --- lib/lrama/lexer/token/user_code.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/lrama/lexer/token/user_code.rb b/lib/lrama/lexer/token/user_code.rb index 97122086..1aebcae1 100644 --- a/lib/lrama/lexer/token/user_code.rb +++ b/lib/lrama/lexer/token/user_code.rb @@ -16,20 +16,19 @@ def references def _references scanner = StringScanner.new(s_value) - references = [] - until scanner.eos? do - case - when reference = scan_reference(scanner) - references << reference - when scanner.scan(/\/\*/) - scanner.scan_until(/\*\//) - else - scanner.getch + Enumerator.new do |y| + until scanner.eos? + case + when reference = scan_reference(scanner) + y << reference + when scanner.scan(/\/\*/) + scanner.scan_until(/\*\//) + else + scanner.getch + end end - end - - references + end.to_a end def scan_reference(scanner)