Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`unused variable` warning is reported when grammer definition includes `*` qualifier

オープン
#309 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@ydah がすでに取り組んでいます。

2026年1月22日 から。

  • #310 @ydah による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
ruby
領域
compilers

調査の方向性

* 修飾子と生成された test.tab.rb を使う文法から始め、特にレポートに示されている _reduce_1 メソッドと _reduce_2 メソッドを確認します。racc test.y に続けて ruby -W test.tab.rb を実行して警告を再現し、修飾子ありと修飾子なしで生成された還元を比較します。再現した文法で未使用の result に関する警告が報告されなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Ruby reports unused variable warning for source file generated from the grammar definition includes * qualifier.

How to reproduce:

Give the source file geneated from the grammer definition below to Ruby with -W option.

class TestParser
options no_result_var

rule
  root
    : 'a' 'b'*
$ racc --version
racc version 1.8.1
$ racc test.y
$ ruby -W test.tab.rb
test.y:8: warning: assigned but unused variable - result
test.y:8: warning: assigned but unused variable - result

Ruby code below is geneated from the the above grammer definition.

#
# DO NOT MODIFY!!!!
# This file is automatically generated by Racc 1.8.1
# from Racc grammar file "test.y".
#

require 'racc/parser.rb'
class TestParser < Racc::Parser
##### State transition tables begin ###

racc_action_table = [
     2,     3,     4,     6,     4 ]

racc_action_check = [
     0,     1,     2,     3,     4 ]

racc_action_pointer = [
    -2,     1,    -1,     3,     1,   nil,   nil,   nil ]

racc_action_default = [
    -4,    -4,    -1,    -4,    -1,    -3,     8,    -2 ]

racc_goto_table = [
     5,     1,     7 ]

racc_goto_check = [
     2,     1,     2 ]

racc_goto_pointer = [
   nil,     1,    -2 ]

racc_goto_default = [
   nil,   nil,   nil ]

racc_reduce_table = [
  0, 0, :racc_error,
  0, 6, :_reduce_1,
  2, 6, :_reduce_2,
  2, 5, :_reduce_none ]

racc_reduce_n = 4

racc_shift_n = 8

racc_token_table = {
  false => 0,
  :error => 1,
  "a" => 2,
  "b" => 3 }

racc_nt_base = 4

racc_use_result_var = false

Racc_arg = [
  racc_action_table,
  racc_action_check,
  racc_action_default,
  racc_action_pointer,
  racc_goto_table,
  racc_goto_check,
  racc_goto_default,
  racc_goto_pointer,
  racc_nt_base,
  racc_reduce_table,
  racc_token_table,
  racc_shift_n,
  racc_reduce_n,
  racc_use_result_var ]
Ractor.make_shareable(Racc_arg) if defined?(Ractor)

Racc_token_to_s_table = [
  "$end",
  "error",
  "\"a\"",
  "\"b\"",
  "$start",
  "root",
  "\"-many@b\"" ]
Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)

Racc_debug_parser = false

##### State transition tables end #####

# reduce 0 omitted

module_eval(<<'.,.,', 'test.y', 7)
  def _reduce_1(val, _values)
    result = val[1] ? val[1].unshift(val[0]) : val
  end
.,.,

module_eval(<<'.,.,', 'test.y', 7)
  def _reduce_2(val, _values)
    result = val[1] ? val[1].unshift(val[0]) : val
  end
.,.,

# reduce 3 omitted

def _reduce_none(val, _values)
  val[0]
end

end   # class TestParser
主要言語
Yacc
スター
569
フォーク
94
平均マージ
12時間 11分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/racc のほかの issue

ruby/racc の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。